class MyPlugin {
constructor (options) {
this.userOptions = options || { }
}
apply(compiler) {
compiler.hooks.emit.tap('cleanTest', (compilation) => {
for (const name in compilation.assets) {
if (name.endsWith(this.userOptions.target)) {
const contents = compilation.assets[name].source()
const noComments = contents.replace(/\/\*[\s\S]*?\*\//g, '')
compilation.assets[name] = {
source: () => noComments,
size: () => noComments.length
}
}
}
})
}
}
module.exports = MyPlugin