Skip to content

Commit 31b93ca

Browse files
authored
New api for DefinePlugin (#3916)
1 parent 8dd2a8c commit 31b93ca

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/content/plugins/define-plugin.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,24 @@ new webpack.DefinePlugin({
101101
'SERVICE_URL': JSON.stringify('https://dev.example.com')
102102
});
103103
```
104+
105+
### Rebuild
106+
107+
Rebuild where there are changes in runtimeValue.
108+
109+
__webpack.app.config.js__
110+
111+
```javascript
112+
113+
const fileDep = path.resolve(__dirname, 'sample.txt');
114+
115+
new webpack.DefinePlugin({
116+
BUILT_AT: webpack.DefinePlugin.runtimeValue(Date.now, [fileDep])
117+
});
118+
```
119+
120+
The first argument to `runtimeValue` is a `function` that returns the value to be assigned and the second argument is an array of `fileDependencies` (what files to be watch for).
121+
122+
In the previous example, the value of `BUILD_AT` would be the time at which the file passed as `fileDep` was last updated in the file system.
123+
124+
T> Passing `true` as second argument instead of `fileDependencies` will flag the module as uncacheable.

0 commit comments

Comments
 (0)