Use custom build output folder when using create-react-app
Edit your package.json:
"build": "react-scripts build && mv build webapp"
With react-scripts >= 4.0.2
, this is officially supported:
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.
// 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'
Caution: the path specified in BUILD_PATH
will be wiped out without mercy. Double check that your environment variable is specified correctly, especially when using continuous integration.