Skip to content

Commit

Permalink
docs: note that define should be used for CONSTANTS not variables (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sodatea committed Apr 3, 2021
1 parent fa85749 commit b4a1526
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@ export default async ({ command, mode }) => {

- **Type:** `Record<string, string>`

Define global variable replacements. Entries will be defined as globals during dev and statically replaced during build.
Define global constant replacements. Entries will be defined as globals during dev and statically replaced during build.

- Starting from `2.0.0-beta.70`, string values will be used as raw expressions, so if defining a string constant, it needs to be explicitly quoted (e.g. with `JSON.stringify`).

- Replacements are performed only when the match is surrounded by word boundaries (`\b`).

Because it's implemented as straightforward text replacements without any syntax analyzation, we recommend using `define` for CONSTANTS only.

For example, `process.env.FOO` and `__APP_VERSION__` are good fits. But `process` or `global` should not be put into this option. Variables can be shimmed or polyfilled instead.

### plugins

- **Type:** ` (Plugin | Plugin[])[]`
Expand Down

0 comments on commit b4a1526

Please sign in to comment.