Skip to content

Commit

Permalink
feat(plugin): Add plugin hook to allow other plugins to use the manif…
Browse files Browse the repository at this point in the history
…est (#76)

* feat(plugin): Add plugin hook to allow other plugins to use the manifest

* Add test and fix missing semicolon
  • Loading branch information
D34THWINGS authored and mastilver committed Sep 1, 2017
1 parent 35f84ff commit de15a87
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down
36 changes: 36 additions & 0 deletions spec/plugin.integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit de15a87

Please sign in to comment.