You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-2Lines changed: 32 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,14 @@ Usage
10
10
11
11
🚧 **Work in progress** 🚧
12
12
13
-
A Heroku app uses this buildpack + an [npm module](https://github.com/mars/heroku-js-runtime-env).
13
+
A Heroku app uses this buildpack + an [npm module](https://github.com/mars/heroku-js-runtime-env).
14
+
15
+
`RUNTIME_JS_`-prefixed environment variables will be made available in the running Heroku app via npm module [heroku-js-runtime-env](https://github.com/mars/heroku-js-runtime-env).
14
16
15
17
### with Vue
16
18
19
+
⚠️ Vue's `npm run dev` mode does pass arbitrary env vars instead requiring settings in `config/dev.env.js`. So, dev mode seems to be broken. (Help?)
20
+
17
21
✏️ *Replace `$APP_NAME` with your app's unique name.*
git commit -m 'Serve it with static site buildpack'
40
+
```
35
41
36
-
# Add Heroku build hook to `package.json`
42
+
Add Heroku build hook to `package.json`. Merge the following `"heroku-postbuild"` property into the existing `"scripts"` section:
43
+
44
+
```json
37
45
{
38
46
"scripts": {
39
47
"heroku-postbuild": "npm run build"
40
48
}
41
49
}
50
+
```
51
+
52
+
Then, commit this change:
53
+
54
+
```
42
55
git add package.json
43
56
git commit -m 'Add Heroku build hook to `package.json`'
44
57
```
@@ -61,6 +74,23 @@ export default {
61
74
</script>
62
75
```
63
76
77
+
Then, commit this code & deploy the app:
78
+
79
+
```bash
80
+
git add src/components/HelloWorld.vue
81
+
git commit -m 'Implement runtimeEnv() in a component'
82
+
git push heroku master
83
+
84
+
heroku open
85
+
```
86
+
87
+
Once deployed, you can set the `RUNTIME_JS_MESSAGE` var to see the new value take effect immediately after the app restarts:
88
+
89
+
```bash
90
+
heroku config:set JS_RUNTIME_MESSAGE=🌈
91
+
heroku open
92
+
```
93
+
64
94
Background
65
95
-----------
66
96
Normally javascript apps are compiled into a bundle before being deployed. During this build phase, environment variables may be embedded in the javascript bundle, such as with [Webpack DefinePlugin](https://webpack.github.io/docs/list-of-plugins.html#defineplugin).
0 commit comments