parent
c4ee1738e7
commit
d5c4e08457
40
index.js
40
index.js
|
|
@ -35,22 +35,20 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) {
|
|||
|
||||
compiler.plugin('make', function(compilation, callback) {
|
||||
// Compile the template (queued)
|
||||
compilationPromise = getNextCompilationSlot(compiler, function() {
|
||||
return childCompiler.compileTemplate(self.options.template, compiler.context, self.options.filename, compilation)
|
||||
.catch(function(err) {
|
||||
compilation.errors.push(prettyError(err, compiler.context).toString());
|
||||
return {
|
||||
content: self.options.showErrors ? prettyError(err, compiler.context).toJsonHtml() : 'ERROR',
|
||||
};
|
||||
})
|
||||
.then(function(compilationResult) {
|
||||
// If the compilation change didnt change the cache is valid
|
||||
isCompilationCached = compilationResult.hash && self.hash === compilationResult.hash;
|
||||
self.hash = compilation.hash;
|
||||
callback();
|
||||
return compilationResult.content;
|
||||
});
|
||||
});
|
||||
compilationPromise = childCompiler.compileTemplate(self.options.template, compiler.context, self.options.filename, compilation)
|
||||
.catch(function(err) {
|
||||
compilation.errors.push(prettyError(err, compiler.context).toString());
|
||||
return {
|
||||
content: self.options.showErrors ? prettyError(err, compiler.context).toJsonHtml() : 'ERROR'
|
||||
};
|
||||
})
|
||||
.then(function(compilationResult) {
|
||||
// If the compilation change didnt change the cache is valid
|
||||
isCompilationCached = compilationResult.hash && self.hash === compilationResult.hash;
|
||||
self.hash = compilation.hash;
|
||||
callback();
|
||||
return compilationResult.content;
|
||||
});
|
||||
});
|
||||
|
||||
compiler.plugin('after-compile', function(compilation, callback) {
|
||||
|
|
@ -498,14 +496,4 @@ HtmlWebpackPlugin.prototype.getFullTemplatePath = function(template, context) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to prevent html-plugin compilation in parallel
|
||||
* Fixes "No source available" where incomplete cache modules were used
|
||||
*/
|
||||
function getNextCompilationSlot(compiler, newEntry) {
|
||||
compiler.HtmlWebpackPluginQueue = (compiler.HtmlWebpackPluginQueue || Promise.resolve())
|
||||
.then(newEntry);
|
||||
return compiler.HtmlWebpackPluginQueue;
|
||||
}
|
||||
|
||||
module.exports = HtmlWebpackPlugin;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "html-webpack-plugin",
|
||||
"version": "2.6.4",
|
||||
"version": "2.6.5",
|
||||
"description": "Simplifies creation of HTML files to serve your webpack bundles",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
|
|
|
|||
Loading…
Reference in New Issue