-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (33 loc) · 779 Bytes
/
Copy pathindex.js
File metadata and controls
35 lines (33 loc) · 779 Bytes
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
26
27
28
29
30
31
32
33
34
35
class WebpackExcludeEntry{
constructor(patterns){
this.patterns = patterns;
}
apply(compiler){
compiler.hooks.compilation.tap("WebpackExcludeEntry", (compilation) => {
compilation.hooks.processAssets.tap(
{
name: "WebpackExcludeEntry",
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE,
},
(assets) => {
Object.keys(assets)
.filter(asset => {
let match = false,
i = this.patterns.length;
while(i--){
if(this.patterns[i].test(asset)){
match = true;
break;
}
}
return match;
})
.forEach(asset => {
compilation.deleteAsset(asset);
});
},
);
});
}
}
module.exports = WebpackExcludeEntry;