• React新的安装less的方法


    yarn add less less-loader -D
    yarn eject
    

    在webpack.config.js文件中

    const sassRegex = /.(scss|sass)$/;
    const sassModuleRegex = /.module.(scss|sass)$/;
    在下面新增两条
    const lessRegex = /.less$/;
    const lessModuleRegex = /.module.less$/;
    
       {
                  test: sassRegex,
                  exclude: sassModuleRegex,
                  use: getStyleLoaders(
                    {
                      importLoaders: 2,
                      sourceMap: isEnvProduction && shouldUseSourceMap,
                    },
                    'sass-loader'
                  ),
                  sideEffects: true,
                },
                  //对应的增加一条
                    
                   {
                  test: lessRegex,
                  exclude: sassModuleRegex,
                  use: getStyleLoaders(
                    {
                      importLoaders: 2,
                      sourceMap: isEnvProduction && shouldUseSourceMap,
                    },
                    'less-loader'
                  ),
                  sideEffects: true,
                },
                      {
                  test: sassModuleRegex,
                  use: getStyleLoaders(
                    {
                      importLoaders: 2,
                      sourceMap: isEnvProduction && shouldUseSourceMap,
                      modules: true,
                      getLocalIdent: getCSSModuleLocalIdent,
                    },
                    'sass-loader'
                  ),
                },
                    //对应的增加一条
                {
                  test: lessModuleRegex,
                  use: getStyleLoaders(
                    {
                      importLoaders: 2,
                      sourceMap: isEnvProduction && shouldUseSourceMap,
                      modules: true,
                      getLocalIdent: getCSSModuleLocalIdent,
                    },
                    'less-loader'
                  ),
                },
    

    运行的时候发现Error: Cannot find module '@babel/core'错误

    //更新到最新版本就可以了
    npm install -D babel-loader @babel/core @babel/preset-env webpack
    

    ////////////////////////////////////////////............................................................................................................................................................................../////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////############################################################################################################################################################################################################################################################

  • 相关阅读:
    Delphi线程的终止
    Delphi线程简介---Create及其参数、Resume、Suspend
    谈谈Delphi中的类和对象4---类是一种对数据和操作高度的封装机制 && 类是一种代码重用机制
    LeetCode:链表排序
    LeetCode 二叉树的最小深度
    hadoop的集群安装
    java线程池分析和应用
    Java thread中对异常的处理策略
    Thread interrupt方法解析
    如何偷Android的内存-Tricking Android MemoryFile
  • 原文地址:https://www.cnblogs.com/fangdongdemao/p/10947229.html
Copyright © 2020-2023  润新知