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).
Try ejecting the config files, by running:
then you'll find a config folder created in your project. You will find your webpack config files init.
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`
Webpack config used by
create-react-app
is here: https://github.com/facebook/create-react-app/tree/master/packages/react-scripts/configFrom the documentation:
If you want to have access to the config files, you need to eject by running:
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.If you want to find webpack files and configurations go to your package.json file and look for scripts
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.
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.