使用 react-app-rewired

react-app-rewired 传送门

安装 react-app-rewired

npm install react-app-rewired --save-dev

项目根目录创建 onfig-overrides.js

/* config-overrides.js */
module.exports = function override(config, env) {
  //do stuff with the webpack config...
  return config;
}

进入package.json 修改命令

  "scripts": {
-   "start": "react-scripts start",
+   "start": "react-app-rewired start",
-   "build": "react-scripts build",
+   "build": "react-app-rewired build",
-   "test": "react-scripts test --env=jsdom",
+   "test": "react-app-rewired test --env=jsdom",
    "eject": "react-scripts eject"
}

onfig-overrides.js文件里添加webpack配置

使用react-app-rewire-less添加Less

react-app-rewire-less传送门

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐