Last active
June 9, 2020 22:45
-
-
Save saidbouhmouch/46bdd8e8ff94248bebea6e1a5bd79fa9 to your computer and use it in GitHub Desktop.
Laravel : set resolve alias in Laravel mix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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