where is create-react-app webpack config and files?

后端 未结 10 1536
长发绾君心
长发绾君心 2020-11-28 18:33

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-cr

相关标签:
10条回答
  • 2020-11-28 18:52

    I know it's pretty late, but for future people stumbling upon this issue, if you want to have access to the webpack config of CRA, there's no other way except you have to run:

    $ npm run eject
    

    However, with ejection, you'll strip away yourself from CRA pipeline of updates, therefore from the point of ejection, you have to maintain it yourself.

    I have come across this issue many times, and therefore I've created a template for react apps which have most of the same config as CRA, but also additional perks (like styled-components, jest unit test, Travis ci for deployments, prettier, ESLint, etc...) to make the maintenance easier. Check out the repo.

    0 讨论(0)
  • 2020-11-28 18:55

    You can find it inside the /config folder.

    When you eject you get a message like:

     Adding /config/webpack.config.dev.js to the project
     Adding /config/webpack.config.prod.js to the project
    
    0 讨论(0)
  • 2020-11-28 18:55

    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.

    0 讨论(0)
  • 2020-11-28 18:58

    Ejecting is not the best option as well as editing something under node_modules. react-app-rewired is not maintained and has the warning:

    ...you now "own" the configs. No support will be provided. Proceed with caution...

    Solution - use craco.

    0 讨论(0)
提交回复
热议问题