Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saidbouhmouch/46bdd8e8ff94248bebea6e1a5bd79fa9 to your computer and use it in GitHub Desktop.
Save saidbouhmouch/46bdd8e8ff94248bebea6e1a5bd79fa9 to your computer and use it in GitHub Desktop.
Laravel : set resolve alias in Laravel mix
Add the following config at the beginning of webpack.mix.js.
let mix = require('laravel-mix');
const path = require('path')
mix.webpackConfig({
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@components': path.resolve(__dirname, 'resources/js/app/components'),
'@services': path.resolve(__dirname, 'resources/js/app/services')
}
}
});
Then, we can import like this:
import UserComponent from '@components/UserComponent'
import { userService } from '@services/user.service'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment