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

后端 未结 10 1594
长发绾君心
长发绾君心 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:44

    The files are located in your node_modules/react-scripts folder:

    Webpack config:

    https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.js

    Start Script:

    https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/scripts/start.js

    Build Script:

    https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/scripts/build.js

    Test Script:

    https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/scripts/test.js

    and so on ...

    Now, the purpose of CRA is not to worry about these.

    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.

提交回复
热议问题