Facebook provides a create-react-app
command to build react apps. When we run npm run build
, we see output in /build
folder.
If you have arrived at this question three years after its initial posting because this is still a problem for you, consider backing this proposal to support a new BUILD_PATH
environment variable.
https://github.com/facebook/create-react-app/pull/8986
From the proposal's documentation:
By default, Create React App will output compiled assets to a
/build
directory adjacent to/src
. You may use this variable to specify a new path for Create React App to output assets.BUILD_PATH
should be specified as a path relative to the root of your project.
If this proposal is adopted, it would mean that customizing the output target for create-react-app becomes as simple as updating updating your build script:
// package.json
"scripts": {
"build": "BUILD_PATH='./dist' react-scripts build",
// ...
},
or adding a .env file to the root of your project:
# .env
BUILD_PATH='./dist'