html-webpack-plugin
Advanced tools
Comparing version 2.2.0 to 2.3.0
39
index.js
@@ -100,6 +100,26 @@ 'use strict'; | ||
}) | ||
// Allow plugins to change the html before assets are injected | ||
.then(function(html) { | ||
return new Promise(function(resolve){ | ||
var pluginArgs = {html: html, assets: assets, plugin: self}; | ||
compilation.applyPluginsAsyncWaterfall('html-webpack-plugin-before-html-processing', pluginArgs, | ||
function() { | ||
resolve(pluginArgs.html); | ||
}); | ||
}); | ||
}) | ||
.then(function(html) { | ||
// Add the stylesheets, scripts and so on to the resulting html | ||
return self.postProcessHtml(html, assets); | ||
}) | ||
// Allow plugins to change the html after assets are injected | ||
.then(function(html) { | ||
return new Promise(function(resolve){ | ||
var pluginArgs = {html: html, assets: assets, plugin: self}; | ||
compilation.applyPluginsAsyncWaterfall('html-webpack-plugin-after-html-processing', pluginArgs, | ||
function() { | ||
resolve(pluginArgs.html); | ||
}); | ||
}); | ||
}) | ||
.catch(function(err) { | ||
@@ -122,3 +142,7 @@ // In case anything went wrong the promise is resolved | ||
}; | ||
callback(); | ||
// Let other plugins know that we are done: | ||
compilation.applyPluginsAsyncWaterfall('html-webpack-plugin-after-emit', { | ||
html: compilation.assets[self.options.filename], | ||
plugin: self | ||
}, callback); | ||
}); | ||
@@ -429,17 +453,8 @@ }); | ||
HtmlWebpackPlugin.prototype.injectAssetsIntoHtml = function(html, assets) { | ||
var chunks = Object.keys(assets.chunks); | ||
// Gather all css and script files | ||
var styles = []; | ||
var scripts = []; | ||
chunks.forEach(function(chunkName) { | ||
styles = styles.concat(assets.chunks[chunkName].css); | ||
scripts.push(assets.chunks[chunkName].entry); | ||
}); | ||
// Turn script files into script tags | ||
scripts = scripts.map(function(scriptPath) { | ||
var scripts = assets.js.map(function(scriptPath) { | ||
return '<script src="' + scriptPath + '"></script>'; | ||
}); | ||
// Turn css files into link tags | ||
styles = styles.map(function(stylePath) { | ||
var styles = assets.css.map(function(stylePath) { | ||
return '<link href="' + stylePath + '" rel="stylesheet">'; | ||
@@ -446,0 +461,0 @@ }); |
{ | ||
"name": "html-webpack-plugin", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Simplifies creation of HTML files to serve your webpack bundles", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -266,1 +266,18 @@ HTML Webpack Plugin | ||
Events | ||
------ | ||
To allow other plugins to alter the html this plugin executes the following events: | ||
* `html-webpack-plugin-before-html-processing` | ||
* `html-webpack-plugin-after-html-processing` | ||
* `html-webpack-plugin-after-emit` | ||
Usage: | ||
``` | ||
compilation.plugin('html-webpack-plugin-before-html-processing', function(htmlPluginData, callback) { | ||
htmlPluginData.html += 'The magic footer'; | ||
callback(); | ||
}); | ||
``` |
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
31071
516
283