Skip to content

Commit

Permalink
docs(replace): clarify options for allowed replacement values (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-vanraes committed Jun 1, 2020
1 parent c599182 commit 6446657
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/replace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ export default {
dir: 'output',
format: 'cjs'
},
plugins: [replace({ __buildEnv__: 'production' })]
plugins: [replace({
__buildEnv__: 'production',
__buildDate__: () => new Date(),
__buildVersion: 15
})]
};
```

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).

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`._
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`._

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

Expand Down

0 comments on commit 6446657

Please sign in to comment.