sass全局变量

2020-09-30  本文已影响0人  DTripper

npm eject 显示隐藏文件

npm install sass-resources-loader -D

/**
* webpack.config.js
* 新增concat部分
* 
*/

//react,项目中所有scss文件均可使用变量和方法,无需再次单独引入
{
    test: sassRegex,
    exclude: sassModuleRegex,
    use: getStyleLoaders(
    {
        importLoaders: 3,
        sourceMap: isEnvProduction && shouldUseSourceMap,
    },
    'sass-loader'
    ).concat({
        loader:'sass-resources-loader',
        optionss:{
            resources:[
                //这里按照实际文件路径填写
                path.resolve(__dirname,'./../src/styles/main.scss')
            ]
        }
    }),
    // Don't consider CSS imports dead code even if the
    // containing package claims to have no side effects.
    // Remove this when webpack adds a warning or an error for this.
    // See https://github.com/webpack/webpack/issues/6571
    sideEffects: true,
},
上一篇 下一篇

猜你喜欢

热点阅读