Created
February 11, 2020 21:32
-
-
Save SarKurd/222f1258871277c0cc295a6add4369c5 to your computer and use it in GitHub Desktop.
Mini css extract plugin clean up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //https://github.com/webpack/webpack/issues/7300#issuecomment-413959996 | |
| class MiniCssExtractPluginCleanUp { | |
| constructor(deleteWhere = /styles(\.[^.]+)?\.js(\.map)?$/) { | |
| this.shouldDelete = new RegExp(deleteWhere); | |
| } | |
| apply(compiler) { | |
| compiler.hooks.emit.tapAsync('MiniCssExtractPluginCleanup', (compilation, callback) => { | |
| Object.keys(compilation.assets).forEach(asset => { | |
| if (this.shouldDelete.test(asset)) { | |
| delete compilation.assets[asset]; | |
| } | |
| }); | |
| callback(); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment