Skip to content

Commit 8fa0a26

Browse files
authoredFeb 3, 2021
Add support for new BUILD_PATH advanced configuration variable (#8986)
1 parent 6a39607 commit 8fa0a26

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed
 

‎docusaurus/docs/advanced-configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ You can adjust various development and production settings by setting environmen
1818
| WDS_SOCKET_PATH | ✅ Used | 🚫 Ignored | When set, Create React App will run the development server with a custom websocket path for hot module reloading. Normally, `webpack-dev-server` defaults to `/sockjs-node` for the SockJS pathname. You may use this variable to start local development on more than one Create React App project at a time. See [webpack-dev-server documentation](https://webpack.js.org/configuration/dev-server/#devserversockpath) for more details. |
1919
| WDS_SOCKET_PORT | ✅ Used | 🚫 Ignored | When set, Create React App will run the development server with a custom websocket port for hot module reloading. Normally, `webpack-dev-server` defaults to `window.location.port` for the SockJS port. You may use this variable to start local development on more than one Create React App project at a time. See [webpack-dev-server documentation](https://webpack.js.org/configuration/dev-server/#devserversockport) for more details. |
2020
| PUBLIC_URL | ✅ Used | ✅ Used | Create React App assumes your application is hosted at the serving web server's root or a subpath as specified in [`package.json` (`homepage`)](deployment#building-for-relative-paths). Normally, Create React App ignores the hostname. You may use this variable to force assets to be referenced verbatim to the url you provide (hostname included). This may be particularly useful when using a CDN to host your application. |
21+
| BUILD_PATH | 🚫 Ignored | ✅ Used | By default, Create React App will output compiled assets to a `/build` directory adjacent to your `/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. |
2122
| CI | ✅ Used | ✅ Used | When set to `true`, Create React App treats warnings as failures in the build. It also makes the test runner non-watching. Most CIs set this flag by default. |
2223
| REACT_EDITOR | ✅ Used | 🚫 Ignored | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebook/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH](<https://en.wikipedia.org/wiki/PATH_(variable)>) environment variable points to your editor’s bin folder. You can also set it to `none` to disable it completely. |
2324
| CHOKIDAR_USEPOLLING | ✅ Used | 🚫 Ignored | When set to `true`, the watcher runs in polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes. |

‎packages/react-scripts/config/paths.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const publicUrlOrPath = getPublicUrlOrPath(
2929
process.env.PUBLIC_URL
3030
);
3131

32+
const buildPath = process.env.BUILD_PATH || 'build';
33+
3234
const moduleFileExtensions = [
3335
'web.mjs',
3436
'mjs',
@@ -60,7 +62,7 @@ const resolveModule = (resolveFn, filePath) => {
6062
module.exports = {
6163
dotenv: resolveApp('.env'),
6264
appPath: resolveApp('.'),
63-
appBuild: resolveApp('build'),
65+
appBuild: resolveApp(buildPath),
6466
appPublic: resolveApp('public'),
6567
appHtml: resolveApp('public/index.html'),
6668
appIndexJs: resolveModule(resolveApp, 'src/index'),
@@ -83,7 +85,7 @@ const resolveOwn = relativePath => path.resolve(__dirname, '..', relativePath);
8385
module.exports = {
8486
dotenv: resolveApp('.env'),
8587
appPath: resolveApp('.'),
86-
appBuild: resolveApp('build'),
88+
appBuild: resolveApp(buildPath),
8789
appPublic: resolveApp('public'),
8890
appHtml: resolveApp('public/index.html'),
8991
appIndexJs: resolveModule(resolveApp, 'src/index'),
@@ -119,7 +121,7 @@ if (
119121
module.exports = {
120122
dotenv: resolveOwn(`${templatePath}/.env`),
121123
appPath: resolveApp('.'),
122-
appBuild: resolveOwn('../../build'),
124+
appBuild: resolveOwn(path.join('../..', buildPath)),
123125
appPublic: resolveOwn(`${templatePath}/public`),
124126
appHtml: resolveOwn(`${templatePath}/public/index.html`),
125127
appIndexJs: resolveModule(resolveOwn, `${templatePath}/src/index`),

0 commit comments

Comments
 (0)
Please sign in to comment.