Search code examples
npmcreate-react-app

In create-react-app, does the development build 'npm start' get output to the filesystem?


I have a create-react-app. It works great, however, where does the output to npm start get served from, i.e, what is the path on disk? Or does it get served from memory?

I would like to serve that output from IIS to avoid some cross-origins issues with a webservice I am calling but I can't find the physical disk path where npm start is being output.

I would run npm run build every time but it takes a solid 2 minutes and I want the faster build time of the non-optimized build for debugging.


Solution

  • create-react-app uses react-scripts to compile the code. Have you considered setting up dev environments?

    First:

    $ npm install dotenv-cli --save-dev
    

    package.json

        {
          ...
          "scripts": {
             ...,
             "build": "react-scripts build",
             "build-dev": "dotenv -e .env.development 
             react-scripts build",
             ...
          }
          ...
         }
    

    Alternatively, you can run this command and use webpack or something else to bundle

    npm run eject
    

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

    If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

    Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc.) into your project as dependencies in package.json. Technically, the distinction between dependencies and development dependencies is pretty arbitrary for front-end apps that produce static bundles.

    In addition, it used to cause problems with some hosting platforms that didn't install development dependencies (and thus weren't able to build the project on the server or test it right before deployment). You are free to rearrange your dependencies in package.json as you see fit.

    All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

    You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.