Skip to content

Commit

Permalink
Added support for Webpack 5
Browse files Browse the repository at this point in the history
  • Loading branch information
SumoTTo authored and klimashkin committed Dec 9, 2020
1 parent 46713f3 commit e0bfd8b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ module.exports = class PostCSSAssetsPlugin {
}

apply(compiler) {
compiler.hooks.emit.tapPromise(pluginName, (compilation) => this.run(compilation));
const stage = compiler.createCompilation().constructor.PROCESS_ASSETS_STAGE_OPTIMIZE;

if (stage) {
compiler.hooks.compilation.tap(pluginName, (compilation) => {
const stageSettings = { name: pluginName, stage };
compilation.hooks.processAssets.tapPromise(stageSettings, () => this.run(compilation));
});
} else {
compiler.hooks.emit.tapPromise(pluginName, (compilation) => this.run(compilation));
}
}
};

0 comments on commit e0bfd8b

Please sign in to comment.