Update documentation

This commit is contained in:
Jan Nicklas 2015-05-07 08:51:47 +02:00
parent 8b97335192
commit 5043ac0712
3 changed files with 12 additions and 4 deletions

View File

@ -84,6 +84,10 @@ Allowed values are as follows:
- `title`: The title to use for the generated HTML document.
- `filename`: The file to write the HTML to. Defaults to `index.html`.
You can specify a subdirectory here too (eg: `assets/admin.html`).
- `template`: A html template (supports [blueimp templates](https://github.com/blueimp/JavaScript-Templates)).
- `templateContent`: A html string or a function returning the html (supports [blueimp templates](https://github.com/blueimp/JavaScript-Templates)).
- `inject`: Inject all assets into the given `template` or `templateContent`.
- `minify`: Set to true or pass a [html-minifier](https://github.com/kangax/html-minifier#options-quick-reference) options object to minify the output.
- `hash`: if `true` then append a unique webpack compilation hash to all
included scripts and css files. This is useful for cache busting.

View File

@ -104,20 +104,24 @@ HtmlWebpackPlugin.prototype.getTemplateContent = function(compilation, templateP
*/
HtmlWebpackPlugin.prototype.emitHtml = function(compilation, htmlTemplateContent, templateParams, outputFilename) {
var html;
// blueimp-tmpl processing
try {
html = tmpl(htmlTemplateContent, templateParams);
} catch(e) {
return Promise.reject(new Error('HtmlWebpackPlugin: template error ' + e));
}
// Inject link and script elements into an existing html file
if (this.options.inject) {
html = this.injectAssetsIntoHtml(html, templateParams);
}
if (templateParams.htmlWebpackPlugin.options.minify) {
// Minify the html output
if (this.options.minify) {
var minify = require('html-minifier').minify;
var minify_options = templateParams.htmlWebpackPlugin.options.minify.constructor === Object ? templateParams.htmlWebpackPlugin.options.minify : {};
html = minify(html, minify_options);
// If `options.minify` is set to true use the default minify options
var minifyOptions = _.isObject(this.options.minify) ? this.options.minify : {};
html = minify(html, minifyOptions);
}
compilation.assets[outputFilename] = {

View File

@ -1,6 +1,6 @@
{
"name": "html-webpack-plugin",
"version": "1.3.0",
"version": "1.4.0",
"description": "Simplifies creation of HTML files to serve your webpack bundles",
"main": "index.js",
"files": [