You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/replace/README.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,13 +36,17 @@ export default {
36
36
dir:'output',
37
37
format:'cjs'
38
38
},
39
-
plugins: [replace({ __buildEnv__:'production' })]
39
+
plugins: [replace({
40
+
__buildEnv__:'production',
41
+
__buildDate__: () =>newDate(),
42
+
__buildVersion:15
43
+
})]
40
44
};
41
45
```
42
46
43
47
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).
44
48
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`._
46
50
47
51
Typically, `@rollup/plugin-replace` should be placed in `plugins`_before_ other plugins so that they may apply optimizations, such as dead code removal.
0 commit comments