diff --git a/lib/plugin.js b/lib/plugin.js index 7111cf6..95790e4 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -159,7 +159,7 @@ ManifestPlugin.prototype.apply = function(compiler) { fse.outputFileSync(outputFile, json); } - compileCallback(); + compilation.applyPluginsAsync('webpack-manifest-plugin-after-emit', manifest, compileCallback); }.bind(this)); }; diff --git a/spec/plugin.integration.spec.js b/spec/plugin.integration.spec.js index 28469ee..039bfe0 100644 --- a/spec/plugin.integration.spec.js +++ b/spec/plugin.integration.spec.js @@ -60,6 +60,42 @@ describe('ManifestPlugin using real fs', function() { done(); }); }); + + it('exposes a plugin hook with the manifest content', function (done) { + function TestPlugin() { + this.manifest = null; + } + TestPlugin.prototype.apply = function (compiler) { + var self = this; + compiler.plugin('compilation', function (compilation) { + compilation.plugin('webpack-manifest-plugin-after-emit', function (manifest, callback) { + self.manifest = manifest; + callback(); + }); + }); + }; + + var testPlugin = new TestPlugin(); + webpackCompile({ + context: __dirname, + output: { + filename: '[name].js', + path: path.join(__dirname, 'output/single-file') + }, + entry: './fixtures/file.js', + plugins: [ + new ManifestPlugin(), + testPlugin + ] + }, {}, function() { + expect(testPlugin.manifest).toBeDefined(); + expect(testPlugin.manifest).toEqual({ + 'main.js': 'main.js' + }); + + done(); + }); + }); }); describe('watch mode', function() {