|
2 | 2 | * #### Import members from **@edx/frontend-platform**
|
3 | 3 | *
|
4 | 4 | * The configuration module provides utilities for working with an application's configuration
|
5 |
| - * document (ConfigDocument). Configuration environment variables can be supplied to the |
6 |
| - * application in four different ways: |
| 5 | + * document (ConfigDocument). Configuration variables can be supplied to the |
| 6 | + * application in four different ways. They are applied in the following order: |
7 | 7 | *
|
8 |
| - * ##### Build-time Environment Variables |
| 8 | + * - Build-time Configuration |
| 9 | + * - Environment Variables |
| 10 | + * - JavaScript File |
| 11 | + * - Runtime Configuration |
| 12 | + * |
| 13 | + * Last one in wins. Variables with the same name defined via the later methods will override any |
| 14 | + * defined using an earlier method. i.e., if a variable is defined in Runtime Configuration, that |
| 15 | + * will override the same variable defined in either Build-time Configuration method (environment |
| 16 | + * variables or JS file). Configuration defined in a JS file will override environment variables. |
| 17 | + * |
| 18 | + * ##### Build-time Configuration |
| 19 | + * |
| 20 | + * Build-time configuration methods add config variables into the app when it is built by webpack. |
| 21 | + * This saves the app an API call and means it has all the information it needs to initialize right |
| 22 | + * away. There are two methods of supplying build-time configuration: environment variables and a |
| 23 | + * JavaScript file. |
| 24 | + * |
| 25 | + * ######Environment Variables |
9 | 26 | *
|
10 | 27 | * A set list of required config variables can be supplied as
|
11 | 28 | * command-line environment variables during the build process.
|
|
19 | 36 | * Note that additional variables _cannot_ be supplied via this method without using the `config`
|
20 | 37 | * initialization handler. The app won't pick them up and they'll appear `undefined`.
|
21 | 38 | *
|
22 |
| - * ##### JavaScript File Configuration |
| 39 | + * This configuration method is being deprecated in favor of JavaScript File Configuration. |
23 | 40 | *
|
24 |
| - * Configuration variables can be supplied in an optional file |
25 |
| - * named env.config.js. This file must export either an Object containing configuration variables |
26 |
| - * or a function. The function must return an Object containing configuration variables or, |
27 |
| - * alternately, a promise which resolves to an Object. |
| 41 | + * ###### JavaScript File Configuration |
| 42 | + * |
| 43 | + * Configuration variables can be supplied in an optional file named env.config.js. This file must |
| 44 | + * export either an Object containing configuration variables or a function. The function must |
| 45 | + * return an Object containing configuration variables or, alternately, a promise which resolves to |
| 46 | + * an Object. |
| 47 | + * |
| 48 | + * Using a function or async function allows the configuration to be resolved at runtime (because |
| 49 | + * the function will be executed at runtime). This is not common, and the capability is included |
| 50 | + * for the sake of flexibility. |
| 51 | + * |
| 52 | + * JavaScript File Configuration is well-suited to extensibility use cases or component overrides, |
| 53 | + * in that the configuration file can depend on any installed JavaScript module. It is also the |
| 54 | + * preferred way of doing build-time configuration if runtime configuration isn't used by your |
| 55 | + * deployment of the platform. |
28 | 56 | *
|
29 | 57 | * Exporting a config object:
|
30 | 58 | * ```
|
|
59 | 87 | *
|
60 | 88 | * ##### Runtime Configuration
|
61 | 89 | *
|
62 |
| - * Configuration variables can also be supplied using the "runtime |
63 |
| - * configuration" method, taking advantage of the Micro-frontend Config API in edx-platform. |
64 |
| - * More information on this API can be found in the ADR which introduced it: |
| 90 | + * Configuration variables can also be supplied using the "runtime configuration" method, taking |
| 91 | + * advantage of the Micro-frontend Config API in edx-platform. More information on this API can be |
| 92 | + * found in the ADR which introduced it: |
65 | 93 | *
|
66 | 94 | * https://github.com/openedx/edx-platform/blob/master/lms/djangoapps/mfe_config_api/docs/decisions/0001-mfe-config-api.rst
|
67 | 95 | *
|
68 | 96 | * The runtime configuration method can be enabled by supplying a MFE_CONFIG_API_URL via one of the other
|
69 | 97 | * two configuration methods above.
|
70 | 98 | *
|
| 99 | + * Runtime configuration is particularly useful if you need to supply different configurations to |
| 100 | + * a single deployment of a micro-frontend, for instance. It is also a perfectly valid alternative |
| 101 | + * to build-time configuration, though it introduces an additional API call to edx-platform on MFE |
| 102 | + * initialization. |
| 103 | + * |
71 | 104 | * ##### Initialization Config Handler
|
72 | 105 | *
|
73 | 106 | * The configuration document can be extended by
|
|
0 commit comments