Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 411505b

Browse files
authored
Deploy with auto build (mars#156)
* Use Node buildpack‘s auto build * Remove NODE_ENV=development workaround since Node buildpack installs devDeps for build & auto-runs build. * 📚 link to Dev Center for Node.js build customization * Switch to new Node auto build behavior ahead of release * Upgrade to "Node auto build" release version of inner buildpack
1 parent 1b64ebf commit 411505b

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

.buildpacks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
https://github.com/heroku/heroku-buildpack-nodejs.git
2-
https://github.com/mars/create-react-app-inner-buildpack.git#v8.0.0
2+
https://github.com/mars/create-react-app-inner-buildpack.git#v9.0.0
33
https://github.com/heroku/heroku-buildpack-static.git

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ ex: `REACT_APP_FILEPICKER_API_KEY` ([Add-on config vars](#user-content-add-on-co
358358

359359
### Compile-time configuration
360360

361-
Supports [`REACT_APP_`](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables), `NODE_`, `NPM_`, & `HEROKU_` prefixed variables.
361+
Supports all config vars, including [`REACT_APP_`](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables), `NODE_`, `NPM_`, & `HEROKU_` prefixed variables.
362+
363+
☝️🤐 ***Use secrets carefully.** If these values are embedded in the JavaScript bundle, like with `REACT_APP_` vars, then they may be accessed by anyone who can see the React app.*
362364

363365
Use Node's [`process.env` object](https://nodejs.org/dist/latest-v10.x/docs/api/process.html#process_process_env).
364366

@@ -528,15 +530,12 @@ This buildpack combines several buildpacks, specified in [`.buildpacks`](.buildp
528530
* installs `node`, puts on the `$PATH`
529531
* version specified in [`package.json`, `engines.node`](https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version)
530532
* `node_modules/` cached between deployments
531-
* `NODE_ENV` at buildtime:
532-
* defaults to `NODE_ENV=development` to install the build tooling of create-react-app's dev dependencies, like `react-scripts`
533-
* honors specific setting of `NODE_ENV`, like `NODE_ENV=test` for [automated testing](#user-content-testing) in [`bin/test`](bin/test-compile)
534-
* but forces `NODE_ENV=production` to be `development` to ensure dev dependencies are available for build
535-
2. [`mars/create-react-app-inner-buildpack`](https://github.com/mars/create-react-app-inner-buildpack)
536533
* production build for create-react-app
537-
* executes the npm package's build script; create-react-app default is `react-scripts build`
538-
* exposes `REACT_APP_`, `NODE_`, `NPM_`, & `HEROKU_` prefixed env vars to the build script
534+
* [executes the npm package's build script](https://devcenter.heroku.com/changelog-items/1557); create-react-app default is `react-scripts build`
535+
* exposes all env vars to the build script
539536
* generates a production bundle regardless of `NODE_ENV` setting
537+
* customize further with [Node.js build configuration](https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process)
538+
2. [`mars/create-react-app-inner-buildpack`](https://github.com/mars/create-react-app-inner-buildpack)
540539
* sets default [web server config](#user-content-web-server) unless `static.json` already exists
541540
* enables [runtime environment variables](#user-content-environment-variables)
542541
3. [`heroku/static` buildpack](https://github.com/heroku/heroku-buildpack-static)

bin/compile

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ CACHE_DIR=$2
2323
ENV_DIR=$3
2424
BP_DIR=`cd $(dirname $0); cd ..; pwd`
2525

26+
# Switch to new Node auto build behavior ahead of release
27+
export NEW_BUILD_SCRIPT_BEHAVIOR=true
28+
2629
# Use architecture of multi-buildpack to compose behavior.
2730
# https://github.com/heroku/heroku-buildpack-multi
2831
cp $BP_DIR/.buildpacks $BUILD_DIR/.buildpacks
@@ -31,21 +34,6 @@ branch=""
3134
dir=$(mktemp -t buildpackXXXXX)
3235
rm -rf $dir
3336

34-
echo "-----> Configure create-react-app build environment"
35-
# Set env vars for the inner buildpacks in `.buildpacks`
36-
# * during compile, install build tooling (devDependencies) with npm & Yarn
37-
# * in runtime, NODE_ENV is not used (this buildpack launches a static web server)
38-
export NPM_CONFIG_PRODUCTION=false
39-
INHERITED_NODE_ENV="${NODE_ENV:-development}"
40-
if [ "$INHERITED_NODE_ENV" = "production" ]
41-
then
42-
echo ' Setting `NODE_ENV=development` to install dependencies for `npm build`'
43-
export NODE_ENV=development
44-
else
45-
echo " Using \`NODE_ENV=${INHERITED_NODE_ENV}\`"
46-
export NODE_ENV="${INHERITED_NODE_ENV}"
47-
fi
48-
4937
echo "=====> Downloading Buildpack: $url"
5038

5139
if [[ "$url" =~ \.tgz$ ]] || [[ "$url" =~ \.tgz\? ]]; then

0 commit comments

Comments
 (0)