Skip to content

Commit

Permalink
fix: always run hooks last for webpack@4 (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and mastilver committed Apr 19, 2018
1 parent 24acf95 commit f5cc167
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,19 @@ ManifestPlugin.prototype.apply = function(compiler) {

if (compiler.hooks) {
const SyncWaterfallHook = require('tapable').SyncWaterfallHook;
const pluginOptions = {
name: 'ManifestPlugin',
stage: Infinity
};
compiler.hooks.webpackManifestPluginAfterEmit = new SyncWaterfallHook(['manifest']);

compiler.hooks.compilation.tap('ManifestPlugin', function (compilation) {
compilation.hooks.moduleAsset.tap('ManifestPlugin', moduleAsset);
compiler.hooks.compilation.tap(pluginOptions, function (compilation) {
compilation.hooks.moduleAsset.tap(pluginOptions, moduleAsset);
});
compiler.hooks.emit.tap('ManifestPlugin', emit);
compiler.hooks.emit.tap(pluginOptions, emit);

compiler.hooks.run.tap('ManifestPlugin', beforeRun);
compiler.hooks.watchRun.tap('ManifestPlugin', beforeRun);
compiler.hooks.run.tap(pluginOptions, beforeRun);
compiler.hooks.watchRun.tap(pluginOptions, beforeRun);
} else {
compiler.plugin('compilation', function (compilation) {
compilation.plugin('module-asset', moduleAsset);
Expand Down

0 comments on commit f5cc167

Please sign in to comment.