html-webpack-plugin
Advanced tools
+34
-9
@@ -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; |
+2
-2
@@ -24,3 +24,3 @@ 'use strict'; | ||
| var template = _.template(source, options); | ||
| return 'module.exports = ' + template; | ||
| }; | ||
| return 'var _ = require("lodash"); module.exports = ' + template; | ||
| }; |
+1
-1
| { | ||
| "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", |
+1
-1
@@ -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 @@ |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
32533
3.32%549
4.77%3
50%