-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (23 loc) · 894 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author @joeyguo
*/
var ConcatSource = require("webpack-core/lib/ConcatSource");
function WebpackModuleExports(options) {
this.fileRegExp = options && options.fileRegExp;
}
module.exports = WebpackModuleExports;
WebpackModuleExports.prototype.apply = function(compiler) {
var fileRegExp = this.fileRegExp;
compiler.plugin("compilation", function(compilation) {
compilation.plugin("optimize-chunk-assets", function(chunks, callback) {
chunks.forEach(function(chunk) {
chunk.files.forEach(function(file) {
if(fileRegExp && !fileRegExp.test(file)) return;
compilation.assets[file] = new ConcatSource("\nmodule.exports = ", compilation.assets[file]);
});
});
callback();
});
});
};