Skip to content

Commit 6446657

Browse files
docs(replace): clarify options for allowed replacement values (#422)
1 parent c599182 commit 6446657

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/replace/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ export default {
3636
dir: 'output',
3737
format: 'cjs'
3838
},
39-
plugins: [replace({ __buildEnv__: 'production' })]
39+
plugins: [replace({
40+
__buildEnv__: 'production',
41+
__buildDate__: () => new Date(),
42+
__buildVersion: 15
43+
})]
4044
};
4145
```
4246

4347
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
4448

45-
The configuration above will replace every instance of `__buildEnv__` with `'production'` in any file included in the build. _Note: Values should always be strings. For complex values, use `JSON.stringify`._
49+
The configuration above will replace every instance of `__buildEnv__` with `'production'` and `__buildDate__` with the result of the given function in any file included in the build. _Note: Values have to be either primitives or functions that return a string. For complex values, use `JSON.stringify`._
4650

4751
Typically, `@rollup/plugin-replace` should be placed in `plugins` _before_ other plugins so that they may apply optimizations, such as dead code removal.
4852

0 commit comments

Comments
 (0)