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: docs/guide/webpack/README.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,16 +55,16 @@ plugins: [
55
55
]
56
56
```
57
57
58
-
This change tells webpack to add a `<script id="app-config">` tag, which contains
58
+
This change tells webpack to add a `<script id="app-config">` tag, which can contain
59
59
some JavaScript code that sets `window._appConfig`. The loader cooperates with this
60
60
by reading from that global variable instead of inserting the config directly.
61
61
62
62
Why go through this trouble? As stated above, [app-config-inject](./inject.md)
63
63
uses this fact. When you're deploying your frontend application, you can add a
64
64
short injection script that mutates the `index.html` with a new `<script id="app-config">`.
65
65
By doing that, the web app will have different configuration, without changing
66
-
the JavaScript bundle at all. If you really wanted to, you could even change the
67
-
HTML by hand.
66
+
the JavaScript bundle at all (allowing it to be cached). If you really wanted to,
67
+
you could even change the HTML by hand.
68
68
69
69
### Loading Options
70
70
@@ -96,6 +96,21 @@ plugins: [
96
96
]
97
97
```
98
98
99
+
The same goes for schema options. Use the `schemaLoading` property to define custom schema loading options.
100
+
101
+
### Static App Config
102
+
103
+
Use the `noGlobal: true` option and don't enable `headerInjection` - this will result in a statically
104
+
analyzable config object, allowing it to be used like a constant variable (helpful for tree shaking).
105
+
106
+
Note of course, that this has downsides - you can't inject configuration this way. We recommend using
107
+
**multiple app configs** for that reason. You can get the best of both worlds, "feature flags" in one
108
+
configuration file (for tree shaking), and more dynamic/environment configuration in another.
109
+
110
+
### Multiple App Configs
111
+
112
+
This section needs more written about it - you can find an example [here](https://github.com/launchcodedev/app-config/tree/master/tests/webpack-projects/two-app-config-sources).
113
+
99
114
### Validation
100
115
101
116
A niche but useful way to use App Config involves using query parameters as configuration override.
0 commit comments