修改react cra 的项目配置
1 不管是配置什么,最好是安装react-app-rewired 这个包来对 cra 创建的项目进行配置调整
2 安装好之后 在package.json 里把 scripts 里面的启动项替换成 react-app-rewired
"scripts": {// 这是没有替换的 "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" },
"scripts": {//  替换完成
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test",
    "eject": "react-scripts eject"
  },
3 在于package.json 同级目录下 创建 config-overrides.js
const { override, fixBabelImports, addLessLoader } = require("customize-cra");
const modifyVar = require("./src/lessVars");
//使用了less 预处理 和 antd uimodule.exports = override(
  addLessLoader({
    javascriptEnabled: true,
    modifyVars:modifyVar
  }),
  (module.exports = override(
    fixBabelImports("import", {
      libraryName: "antd",
      libraryDirectory: "es",
      style: true
    })
  ))
);
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号