Created by: oliverlaz
This pull request enables build output directory to be configured via special environment variable.
I think this change will come handy in some special environments where build
folder can't be deployed directly.
Default output:
$ yarn build
yarn run v1.3.2
$ cd packages/react-scripts && node bin/react-scripts.js build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
35.56 KB build/static/js/main.c76fe2d2.js
526 B build/static/css/main.de8ab87f.css
The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:
"homepage" : "http://myname.github.io/myapp",
The ../../build folder is ready to be deployed.
Output with build directory override:
$ BUILD_DIR=target/generated-resources/app yarn build
yarn run v1.3.2
$ cd packages/react-scripts && node bin/react-scripts.js build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
35.56 KB app/static/js/main.c76fe2d2.js
526 B app/static/css/main.de8ab87f.css
The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:
"homepage" : "http://myname.github.io/myapp",
The ../../target/generated-resources/app folder is ready to be deployed.
Sidenote:
In my case, I'm bundling a React application as part of a larger Java application. For that purpose, bundle resources should be packaged as a .jar
package and included as a Maven dependency in the parent project.
A precondition for achieving this is to put the bundles in the Maven's generated-resources
directory. In order to fulfill this precondition, either some additional build steps should be added or the app should be ejected. I want to avoid ejection as the default CRA configuration suits fine.