Skip to content

Commit

Permalink
Merge 7e686eb into 09001fe
Browse files Browse the repository at this point in the history
  • Loading branch information
getElementsByName committed Jun 8, 2018
2 parents 09001fe + 7e686eb commit e5a51ce
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function StaticSiteGeneratorWebpackPlugin(options) {
StaticSiteGeneratorWebpackPlugin.prototype.apply = function(compiler) {
var self = this;

compiler.plugin('this-compilation', function(compilation) {
compilation.plugin('optimize-assets', function(_, done) {
addThisCompilationHandler(compiler, function(compilation) {
addOptimizeAssetsHandler(compilation, function(_, done) {
var renderPromises;

var webpackStats = compilation.getStats();
Expand Down Expand Up @@ -224,4 +224,20 @@ function legacyArgsToOptions(entry, paths, locals, globals) {
};
}

function addThisCompilationHandler(compiler, callback) {
if(compiler.hooks) {
compiler.hooks.thisCompilation.tap('static-site-generator-webpack-plugin', callback);
} else {
compiler.plugin('this-compilation', callback);
}
}

function addOptimizeAssetsHandler(compilation, callback) {
if(compilation.hooks) {
compilation.hooks.optimizeAssets.tapAsync('static-site-generator-webpack-plugin',callback);
} else {
compilation.plugin('optimize-assets', callback);
}
}

module.exports = StaticSiteGeneratorWebpackPlugin;

0 comments on commit e5a51ce

Please sign in to comment.