Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Deploy with auto build #156

Merged
merged 5 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildpacks
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/mars/create-react-app-inner-buildpack.git#v8.0.0
https://github.com/mars/create-react-app-inner-buildpack.git#deploy-with-auto-build
https://github.com/heroku/heroku-buildpack-static.git
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ ex: `REACT_APP_FILEPICKER_API_KEY` ([Add-on config vars](#user-content-add-on-co

### Compile-time configuration

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.
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.

☝️🤐 ***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.*

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

Expand Down Expand Up @@ -526,15 +528,15 @@ This buildpack combines several buildpacks, specified in [`.buildpacks`](.buildp
* installs `node`, puts on the `$PATH`
* version specified in [`package.json`, `engines.node`](https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version)
* `node_modules/` cached between deployments
* production build for create-react-app
* [executes the npm package's build script](https://devcenter.heroku.com/changelog-items/1557); create-react-app default is `react-scripts build`
mars marked this conversation as resolved.
Show resolved Hide resolved
* exposes all env vars to the build script
* generates a production bundle regardless of `NODE_ENV` setting
* `NODE_ENV` at buildtime:
* defaults to `NODE_ENV=development` to install the build tooling of create-react-app's dev dependencies, like `react-scripts`
* honors specific setting of `NODE_ENV`, like `NODE_ENV=test` for [automated testing](#user-content-testing) in [`bin/test`](bin/test-compile)
* but forces `NODE_ENV=production` to be `development` to ensure dev dependencies are available for build
2. [`mars/create-react-app-inner-buildpack`](https://github.com/mars/create-react-app-inner-buildpack)
* production build for create-react-app
* executes the npm package's build script; create-react-app default is `react-scripts build`
* exposes `REACT_APP_`, `NODE_`, `NPM_`, & `HEROKU_` prefixed env vars to the build script
* generates a production bundle regardless of `NODE_ENV` setting
* sets default [web server config](#user-content-web-server) unless `static.json` already exists
* enables [runtime environment variables](#user-content-environment-variables)
3. [`heroku/static` buildpack](https://github.com/heroku/heroku-buildpack-static)
Expand Down
15 changes: 0 additions & 15 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ branch=""
dir=$(mktemp -t buildpackXXXXX)
rm -rf $dir

echo "-----> Configure create-react-app build environment"
# Set env vars for the inner buildpacks in `.buildpacks`
# * during compile, install build tooling (devDependencies) with npm & Yarn
# * in runtime, NODE_ENV is not used (this buildpack launches a static web server)
export NPM_CONFIG_PRODUCTION=false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to export NPM_CONFIG_PRODUCTION=true for the Node buildpack and removed in heroku/heroku-buildpack-nodejs#519 which broke a couple of users who were using this ENV var to detect that they were building on Heroku.

Ex: heroku/heroku-buildpack-nodejs#519 (comment)

I don't think there's a way around this, just wanted to call it out

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It felt real good deleting all the NPM/NODE env monkey business. Now this buildpack utilizes/acts like the Node buildpack as much as possible!

INHERITED_NODE_ENV="${NODE_ENV:-development}"
if [ "$INHERITED_NODE_ENV" = "production" ]
then
echo ' Setting `NODE_ENV=development` to install dependencies for `npm build`'
export NODE_ENV=development
else
echo " Using \`NODE_ENV=${INHERITED_NODE_ENV}\`"
export NODE_ENV="${INHERITED_NODE_ENV}"
fi

echo "=====> Downloading Buildpack: $url"

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