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

Commit

Permalink
Support for custom bundle location via JS_RUNTIME_TARGET_BUNDLE (#117)
Browse files Browse the repository at this point in the history
* Support for custom bundle location via `JS_RUNTIME_TARGET_BUNDLE`

* 📚 about custom bundle location

* 📚 how to unset custom bundle path

* Upgrade to inner buildpack with improved custom bundle UX
  • Loading branch information
mars authored Aug 29, 2018
1 parent a27f436 commit b9040a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit b9040a5

Please sign in to comment.