6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Laravel + Vue】ファイルパスに .. を使いたくない【webpackConfig Alias】

Posted at

問題

階層が深いところから、上の呼び出すときに
..がたくさん連なったりしてわかりにくい

App.vue
import Hoge from '../../../components/Hoge'

解決方法

webpackConfigでエイリアスを設定する

webpack.mix.js
mix.webpackConfig({
    resolve: {
        alias: {
            "@": path.resolve(__dirname, "resources/js")
        }
    }
});

これで@/components/Hogeとやれば
/resources/js/components/Hoge見たく展開される

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?