react 配置less

1.执行eject 暴露配置文件

2.安装模块

npm install less less-loader --save-dev

  

3.添加代码

const lessRegex = /\.less$/;
const lessModuleRegex = /\.module\.less$/;

  

4.参照sass添加下面代码

            {
              test: lessRegex,
              exclude: lessModuleRegex,
              use: getStyleLoaders(
                {
                  importLoaders: 3,
                  sourceMap: isEnvProduction && shouldUseSourceMap,
                },
                'less-loader'
              ),
              sideEffects: true,
            },
            {
              test: lessModuleRegex,
              use: getStyleLoaders(
                {
                  importLoaders: 3,
                  sourceMap: isEnvProduction && shouldUseSourceMap,
                  modules: {
                    getLocalIdent: getCSSModuleLocalIdent,
                  },
                },
                'less-loader'
              ),
            },

  

posted @ 2020-04-30 09:22  _心之所向便是光  阅读(274)  评论(0编辑  收藏  举报