不暴露 create react app 的webpack配置下,修改webpack配置
使用 react-app-rewiredreact-app-rewired 传送门安装 react-app-rewirednpm install react-app-rewired --save-dev项目根目录创建 onfig-overrides.js/* config-overrides.js */module.exports = function override(config, env)
·
使用 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
更多推荐
已为社区贡献2条内容
所有评论(0)