html-webpack-plugin
Advanced tools
Comparing version 2.4.0 to 2.5.0
43
index.js
@@ -31,3 +31,3 @@ 'use strict'; | ||
}, options); | ||
// If the template doesn't use a loader use the blueimp template loader | ||
// If the template doesn't use a loader use the lodash template loader | ||
if(this.options.template.indexOf('!') === -1) { | ||
@@ -50,10 +50,18 @@ this.options.template = require.resolve('./loader.js') + '!' + path.resolve(this.options.template); | ||
compiler.plugin('make', function(compilation, callback) { | ||
// Compile the template | ||
compilationPromise = self.compileTemplate(self.options.template, self.options.filename, compilation) | ||
.catch(function(err) { | ||
return new Error(err); | ||
}) | ||
.finally(callback); | ||
// Compile the template (queued) | ||
compilationPromise = getNextCompilationSlot(compiler, function() { | ||
return self.compileTemplate(self.options.template, self.options.filename, compilation) | ||
.catch(function(err) { | ||
return new Error(err); | ||
}) | ||
.finally(callback); | ||
}); | ||
}); | ||
compiler.plugin('after-compile', function(compilation, callback) { | ||
// Clear the compilation queue | ||
delete compiler.HtmlWebpackPluginQueue; | ||
callback(); | ||
}); | ||
compiler.plugin('emit', function(compilation, callback) { | ||
@@ -149,6 +157,14 @@ var applyPluginsAsyncWaterfall = Promise.promisify(compilation.applyPluginsAsyncWaterfall, {context: compilation}); | ||
// Let other plugins know that we are done: | ||
compilation.applyPluginsAsyncWaterfall('html-webpack-plugin-after-emit', { | ||
return applyPluginsAsyncWaterfall('html-webpack-plugin-after-emit', { | ||
html: compilation.assets[self.options.filename], | ||
plugin: self | ||
}, callback); | ||
}); | ||
}) | ||
// Let webpack continue with it | ||
.finally(function(){ | ||
callback(); | ||
// Tell blue bird that we don't want to wait for callback. | ||
// Fixes "Warning: a promise was created in a handler but none were returned from it" | ||
// https://github.com/petkaantonov/bluebird/blob/master/docs/docs/warning-explanations.md#warning-a-promise-was-created-in-a-handler-but-none-were-returned-from-it | ||
return null; | ||
}); | ||
@@ -545,3 +561,12 @@ }); | ||
/** | ||
* Helper to prevent compilation in parallel | ||
* Fixes an issue where incomplete cache modules were used | ||
*/ | ||
function getNextCompilationSlot(compiler, newEntry) { | ||
compiler.HtmlWebpackPluginQueue = (compiler.HtmlWebpackPluginQueue || Promise.resolve()) | ||
.then(newEntry); | ||
return compiler.HtmlWebpackPluginQueue; | ||
} | ||
module.exports = HtmlWebpackPlugin; |
@@ -24,3 +24,3 @@ 'use strict'; | ||
var template = _.template(source, options); | ||
return 'module.exports = ' + template; | ||
}; | ||
return 'var _ = require("lodash"); module.exports = ' + template; | ||
}; |
{ | ||
"name": "html-webpack-plugin", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Simplifies creation of HTML files to serve your webpack bundles", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -174,3 +174,3 @@ HTML Webpack Plugin | ||
You can use the lodash syntax out of the box. | ||
If the `inject` feature doesn't fit your needs and you want full control over the asset placement use the [default template](https://github.com/ampedandwired/html-webpack-plugin/blob/master/default_index.html) | ||
If the `inject` feature doesn't fit your needs and you want full control over the asset placement use the [default template](https://github.com/ampedandwired/html-webpack-plugin/blob/feature/loaders/default_index.html) | ||
as a starting point for writing your own. | ||
@@ -177,0 +177,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32533
549