日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

react全局scss變量

作者:郭俊強 更新時間: 2023-07-15 編程語言

?1、下載包

cnpm i sass-resources-loader -D

2、config中找到webpack.config.js

找到如下位置:

{
    test: sassRegex,
    exclude: sassModuleRegex,
    use: getStyleLoaders(
        {
            importLoaders: 3,
            sourceMap: isEnvProduction
                ? shouldUseSourceMap
                : isEnvDevelopment,
            modules: {
                mode: "icss",
            },
        },
        "sass-loader"
    ),
    // 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,
},

替換:

{
    test: sassRegex,
    exclude: sassModuleRegex,
    use: getStyleLoaders(
        {
            importLoaders: 3,
            sourceMap: isEnvProduction
                ? shouldUseSourceMap
                : isEnvDevelopment,
            modules: {
                mode: "icss",
            },
        },
        "sass-loader"
    ).concat({
        loader:'sass-resources-loader',
        options:{
            resources:['./src/assets/scss/reset.scss','./src/assets/scss/gloab.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,
},

3、重啟項目即可

原文鏈接:https://blog.csdn.net/qq_37061571/article/details/131660739

  • 上一篇:沒有了
  • 下一篇:沒有了
欄目分類
最近更新