Skip to content

Commit

Permalink
Merge pull request #48 from spiltcoffee/Webpack4
Browse files Browse the repository at this point in the history
Updated Webpack Plugin to be compatible with Webpack 4 (fixes #47)
  • Loading branch information
robertknight authored Nov 16, 2018
2 parents b6f355d + fe0b25e commit 8a52b4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class WebpackBundleSizeAnalyzerPlugin {
this.statsOptions = statsOptions;
}
apply(compiler: any) {
compiler.plugin('done', (stats: any) => {
compiler.hooks.done.tap('WebpackBundleSizeAnalyzerPlugin', (stats: any) => {
let filepath = this.filepath;
if (filepath.length > 0) {
stats = stats.toJson(this.statsOptions);
Expand Down
10 changes: 7 additions & 3 deletions tests/plugin_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ describe('WebpackBundleSizeAnalyzerPlugin', () => {
fs.writeFile = fsMock;
compilerMock = {
outputPath: './mock-path',
plugin: (event: any, callback: any) => {
expect(event).toEqual('done');
callback(statsMock);
hooks: {
done: {
tap: (pluginTitle: any, callback: any) => {
expect(pluginTitle).toEqual('WebpackBundleSizeAnalyzerPlugin');
callback(statsMock);
}
}
}
};
statsMock = {
Expand Down

0 comments on commit 8a52b4f

Please sign in to comment.