vue.config.js to (laravel) webpack.mix.js

前端 未结 1 992
余生分开走
余生分开走 2021-01-02 07:18

I started using Vue using the Vue CLI template. In that template you create a file called \'vue.config.js\' to define some settings. More to find here: https://cli.vuejs.org

相关标签:
1条回答
  • 2021-01-02 07:52

    Laravel mix has a shortcut to "indicate a file to include in every component styles" (look for globalVueStyles in the option available). So simply add the code below to the webpack.mix.js file at project root.

    mix.options({
        globalVueStyles: `resources/assets/css/variables.scss`
    });
    

    And install the dependency sass-resources-loader

    npm install --save-dev sass-resources-loader
    

    It works only as relative path. Also, the docs say that this option only works when extractVueStyles is enabled, however it was not needed for me.

    To have more control over "vue-loader" you can use the undocumented function mix.override

    mix.override(webpackConfig => {
        // iterate and modify webpackConfig.module.rules array
    })
    
    0 讨论(0)
提交回复
热议问题