where is create-react-app webpack config and files

2019-03-08 00:58发布

I create a ReactJS project with the create-react-app package and that worked well, but I cannot find webpack files and configurations.

How does react-create-app work with webpack? Where are the webpack configuration files located in a default installation with create-react-app? I'm unable to find configuration files in my project's folders.

I have not created an override config file. I can manage config settings with other articles but I want to find the conventional config file(s).

7条回答
We Are One
2楼-- · 2019-03-08 01:37

Try ejecting the config files, by running:

npm run eject

then you'll find a config folder created in your project. You will find your webpack config files init.

查看更多
仙女界的扛把子
3楼-- · 2019-03-08 01:47

Assuming you don't want to eject and you just want to look at the config you will find them in /node_modules/react-scripts/config webpack.config.dev.js. //used by `npm start` webpack.config.prod.js //used by `npm run build`

查看更多
老娘就宠你
5楼-- · 2019-03-08 01:51

From the documentation:

You don’t need to install or configure tools like Webpack or Babel. They are preconfigured and hidden so that you can focus on the code.

If you want to have access to the config files, you need to eject by running:

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

In most scenarios, it is best not to eject and try to find a way to make it work for you in another way. That way, you can update your dependencies through create-react-app and not have to deal with Webpack dependency hell.

查看更多
ゆ 、 Hurt°
6楼-- · 2019-03-08 01:52

If you want to find webpack files and configurations go to your package.json file and look for scripts

img

You will find that scripts object is using a library react-scripts

Now go to node_modules and look for react-scripts folder react-script-in-node-modules

This react-scripts/scripts and react-scripts/config folder contains all the webpack configurations.

查看更多
再贱就再见
7楼-- · 2019-03-08 01:52

A lot of people come to this page with the goal of finding the webpack config and files in order to add their own configuration to them. Another way to achieve this without running npm run eject is to use react-app-rewired. This allows you to overwrite your webpack config file without ejecting.

查看更多
登录 后发表回答