Skip to content

Commit de15a87

Browse files
D34THWINGSmastilver
authored andcommitted
feat(plugin): Add plugin hook to allow other plugins to use the manifest (#76)
* feat(plugin): Add plugin hook to allow other plugins to use the manifest * Add test and fix missing semicolon
1 parent 35f84ff commit de15a87

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ ManifestPlugin.prototype.apply = function(compiler) {
159159
fse.outputFileSync(outputFile, json);
160160
}
161161

162-
compileCallback();
162+
compilation.applyPluginsAsync('webpack-manifest-plugin-after-emit', manifest, compileCallback);
163163
}.bind(this));
164164
};
165165

spec/plugin.integration.spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,42 @@ describe('ManifestPlugin using real fs', function() {
6060
done();
6161
});
6262
});
63+
64+
it('exposes a plugin hook with the manifest content', function (done) {
65+
function TestPlugin() {
66+
this.manifest = null;
67+
}
68+
TestPlugin.prototype.apply = function (compiler) {
69+
var self = this;
70+
compiler.plugin('compilation', function (compilation) {
71+
compilation.plugin('webpack-manifest-plugin-after-emit', function (manifest, callback) {
72+
self.manifest = manifest;
73+
callback();
74+
});
75+
});
76+
};
77+
78+
var testPlugin = new TestPlugin();
79+
webpackCompile({
80+
context: __dirname,
81+
output: {
82+
filename: '[name].js',
83+
path: path.join(__dirname, 'output/single-file')
84+
},
85+
entry: './fixtures/file.js',
86+
plugins: [
87+
new ManifestPlugin(),
88+
testPlugin
89+
]
90+
}, {}, function() {
91+
expect(testPlugin.manifest).toBeDefined();
92+
expect(testPlugin.manifest).toEqual({
93+
'main.js': 'main.js'
94+
});
95+
96+
done();
97+
});
98+
});
6399
});
64100

65101
describe('watch mode', function() {

0 commit comments

Comments
 (0)