zoukankan      html  css  js  c++  java
  • 在React中使用less

    1.需要暴露出webpack的配置文件

    在终端运行 npm run eject

    2.安装less和less-loader插件

    运行 npm install less-loader less --save

    3.修改webpack的配置文件

    找到config文件夹目录下的webpack.config.js。添加一下代码

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

      

    之后在文件中搜素oneof,增加oneof中的配置代码,之后就可以直接使用了

    {
      test: lessRegex,
      exclude: lessModuleRegex,
      use: getStyleLoaders(
        {
          importLoaders: 2,
          sourceMap: isEnvProduction && shouldUseSourceMap,
        },
        'less-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,
    },
    // Adds support for CSS Modules, but using SASS
    // using the extension .module.scss or .module.sass
    {
      test: lessModuleRegex,
      use: getStyleLoaders(
        {
          importLoaders: 2,
          sourceMap: isEnvProduction && shouldUseSourceMap,
          modules: true,
          getLocalIdent: getCSSModuleLocalIdent,
        },
        'less-loader'
      ),
    },
    

      

  • 相关阅读:
    Python mutilprocessing Processing 父子进程共享文件对象?
    BZOJ4836: [Lydsy1704月赛]二元运算
    博弈论刷题记录
    manacher(无讲解)
    UOJ_407_【IOI2018】狼人
    BZOJ_3935_Rbtree
    dsu on tree(无讲解)
    BZOJ_3744_Gty的妹子序列
    后缀数组(无讲解)
    虚树(无讲解)
  • 原文地址:https://www.cnblogs.com/sisxxw/p/14845504.html
Copyright © 2011-2022 走看看