react+antd+router完成一个后台

2019-04-18  本文已影响0人  一个被程序员耽误的厨师

一、创建一个react项目

create-react-app maqiu_admin
cd maqiu_admin
npm start
npm run eject
* ###5添加如下代码
"homepage":".",

二、安装less,配置项目

cnpm install less less-loader --save
image.png
//less
const lessRegex = /\.less$/;
const lessModuleRegex = /\.module\.less$/;
image.png
if(preProcessor === 'less-loader'){
        loaders.push({
          loader: require.resolve(preProcessor),
          options: {
            sourceMap: isEnvProduction && shouldUseSourceMap,
            javascriptEnabled:true,
            modifyVars:{
              "@primary-color":"#1890ff"
            }
          },
        });
      }else{
        loaders.push({
          loader: require.resolve(preProcessor),
          options: {
            sourceMap: isEnvProduction && shouldUseSourceMap,
          },
        });
      }
image.png
 {
              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'
              ),
            },

三、项目引入antdesign框架

cnpm install -D antd --save
cnpm install babel-plugin-import --save
image.png
"plugins":[
      [
        "import",
        {
          "librayName":"antd",
          "style":true
        }
      ]
    ]
上一篇下一篇

猜你喜欢

热点阅读