Skip to content

Commit 615ccf8

Browse files
committed
docs: more about webpack
1 parent d401d03 commit 615ccf8

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

docs/guide/webpack/README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ plugins: [
5555
]
5656
```
5757

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
5959
some JavaScript code that sets `window._appConfig`. The loader cooperates with this
6060
by reading from that global variable instead of inserting the config directly.
6161

6262
Why go through this trouble? As stated above, [app-config-inject](./inject.md)
6363
uses this fact. When you're deploying your frontend application, you can add a
6464
short injection script that mutates the `index.html` with a new `<script id="app-config">`.
6565
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.
6868

6969
### Loading Options
7070

@@ -96,6 +96,21 @@ plugins: [
9696
]
9797
```
9898

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+
99114
### Validation
100115

101116
A niche but useful way to use App Config involves using query parameters as configuration override.

0 commit comments

Comments
 (0)