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

Support for custom bundle location via JS_RUNTIME_TARGET_BUNDLE #117

Merged
merged 4 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from all 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#v4.0.0
https://github.com/mars/create-react-app-inner-buildpack.git#v5.1.0
https://github.com/heroku/heroku-buildpack-static.git
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ The default `static.json`, if it does not exist in the repo, is:
{ "root": "build/" }
```

### Changing the root

If a different web server `"root"` is specified, such as with a highly customized, ejected create-react-app project, then the new bundle location may need to be [set to enable runtime environment variables](#user-content-custom-bundle-location).

### Routing clean URLs

[React Router](https://github.com/ReactTraining/react-router) (not included) may easily use hash-based URLs like `https://example.com/index.html#/users/me/edit`. This is nice & easy when getting started with local development, but for a public app you probably want real URLs like `https://example.com/users/me/edit`.
Expand Down Expand Up @@ -373,6 +377,22 @@ class App extends Component {

⚠️ *Avoid setting backslash escape sequences, such as `\n`, into Runtime config vars. Use literal UTF-8 values only; they will be automatically escaped.*

#### Custom bundle location

If the javascript bundle location is customized, such as with an ejected created-react-app project, then the runtime may not be able to locate the bundle to inject runtime variables.

To solve this so the runtime can locate the bundle, set the custom bundle path:

```bash
heroku config:set JS_RUNTIME_TARGET_BUNDLE=/app/my/custom/path/js/main.*.js
```

To unset this config and use the default path for **create-react-app**'s bundle, `/app/build/static/js/main.*.js`:

```bash
heroku config:unset JS_RUNTIME_TARGET_BUNDLE
```

### Add-on config vars

🤐 *Be careful not to export secrets. These values may be accessed by anyone who can see the React app.*
Expand Down