Vue-cli4 configures public scss style files

Need to use the sass-resources-loader tool to achieve 

npm install sass-resources-loader

In the root directory of the project, create a new vue.config.js file and add configuration

module.exports = {
    chainWebpack: config => {
        const oneOfsMap = config.module.rule('scss').oneOfs.store
        oneOfsMap.forEach(item => {
            item
                .use('sass-resources-loader')
                .loader('sass-resources-loader')
                .options({
                    // 要公用的scss的路径
                    resources: './public/css/reset.scss'
                })
                .end()
        })
    }
}

 

Guess you like

Origin blog.csdn.net/weixin_42217154/article/details/111351930