如何为使用 create-react-app 创建的 React 项目更新 webpack 配置? [英] How to update webpack config for a react project created using create-react-app?
本文介绍了如何为使用 create-react-app 创建的 React 项目更新 webpack 配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 create-react-app 创建了一个 React 项目.现在我需要更新 webpack 配置,但我在任何地方都找不到该文件.我需要自己创建这个文件还是过程是什么?我刚开始反应,不确定如何从这里开始.
I have created a react project using create-react-app. Now I need to update the webpack config, but I don't find the file anywhere. Do I need to create this file myself or what is the process? I am new to react and not really sure how to proceed from here.
推荐答案
无需运行npm run eject
第一步
npm install react-app-rewired --save-dev
第 2 步
将 config-overrides.js
添加到项目根目录.(不是 ./src)
Add config-overrides.js
to the project root directory.(NOT ./src)
// config-overrides.js
module.exports = function override(config, env) {
// New config, e.g. config.plugins.push...
return config
}
步骤 3
重新启动您的应用.完成
Restart your app. Done
这篇关于如何为使用 create-react-app 创建的 React 项目更新 webpack 配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文