From 3005cec0f911eb990c550b48106c2b1fdd681e0d Mon Sep 17 00:00:00 2001 From: Michael Wolfenden Date: Wed, 2 Mar 2016 13:28:26 +1000 Subject: [PATCH] Add additional compilation property to the templateParam object --- index.js | 3 ++- migration.md | 6 +++--- spec/HtmlWebpackPluginSpec.js | 16 ++++++++++++++++ spec/fixtures/templateParam.js | 3 +++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 spec/fixtures/templateParam.js diff --git a/index.js b/index.js index 7714d4e1..7838ba13 100644 --- a/index.js +++ b/index.js @@ -212,7 +212,8 @@ HtmlWebpackPlugin.prototype.executeTemplate = function (templateFunction, chunks htmlWebpackPlugin: { files: assets, options: self.options - } + }, + compilation: compilation }; var html = ''; try { diff --git a/migration.md b/migration.md index e4695d3c..0938a292 100644 --- a/migration.md +++ b/migration.md @@ -156,16 +156,16 @@ module.exports = '...'; ``` More advanced template.js ```js - module.exports = function(compilationResult, chunks, assets, compilation) { + module.exports = function(templateParams) { return '..'; }; ``` Using loaders inside a template.js ```js // This function has to return a string or promised string: - module.exports = function(compilationResult, chunks, assets, compilation) { + module.exports = function(templateParams) { // Play around with the arguments and then use the webpack jade loader to load the jade: - return require('./template.jade')({assets: assets}); + return require('./template.jade')({assets: templateParams.htmlWebpackPlugin.files}); }; ``` diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index bd567f8e..65dadf1c 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -1047,4 +1047,20 @@ describe('HtmlWebpackPlugin', function () { }, [ /