Skip to content

Commit 16ada23

Browse files
committed
add filename filter to modify path and filename
1 parent 2db50ee commit 16ada23

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ new ExtractTextPlugin([id: string], filename: string, [options])
4848
* `options`
4949
* `allChunks` extract from all additional chunks too (by default it extracts only from the initial chunk(s))
5050
* `disable` disables the plugin
51+
* `filenamefilter` function to modify path and filename before files are emitted
52+
```
53+
{
54+
filenamefilter: function(filename) {
55+
// modify filename
56+
return filename;
57+
}
58+
}
59+
```
5160
5261
The `ExtractTextPlugin` generates an output file per entry, so you must use `[name]`, `[id]` or `[contenthash]` when using multiple entries.
5362

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
302302
}).replace(/\[(?:(\w+):)?contenthash(?::([a-z]+\d*))?(?::(\d+))?\]/ig, function() {
303303
return loaderUtils.getHashDigest(source.source(), arguments[1], arguments[2], parseInt(arguments[3], 10));
304304
});
305+
file = (options.filenamefilter) ? options.filenamefilter(file) : file;
305306
compilation.assets[file] = source;
306307
chunk.files.push(file);
307308
}

0 commit comments

Comments
 (0)