html-webpack-plugin 2.23.0 → 2.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Change History
2
2
  ==============
3
3
 
4
+ v2.24.0
5
+ ---
6
+ * Update dependencies
7
+ * Add deprecate warning for plugins not returning a result
8
+ * Add [path] for favicons
9
+
4
10
  v2.23.0
5
11
  ---
6
12
  * Update dependencies
package/README.md CHANGED
@@ -62,7 +62,7 @@ This will generate a file `dist/index.html` containing the following:
62
62
  If you have multiple webpack entry points, they will all be included with `script`
63
63
  tags in the generated HTML.
64
64
 
65
- If you have any css assets in webpack's output (for example, css extracted
65
+ If you have any CSS assets in webpack's output (for example, CSS extracted
66
66
  with the [ExtractTextPlugin](https://github.com/webpack/extract-text-webpack-plugin))
67
67
  then these will be included with `<link>` tags in the HTML head.
68
68
 
@@ -79,7 +79,7 @@ Allowed values are as follows:
79
79
  - `favicon`: Adds the given favicon path to the output html.
80
80
  - `minify`: `{...} | false` Pass a [html-minifier](https://github.com/kangax/html-minifier#options-quick-reference) options object to minify the output.
81
81
  - `hash`: `true | false` if `true` then append a unique webpack compilation hash to all
82
- included scripts and css files. This is useful for cache busting.
82
+ included scripts and CSS files. This is useful for cache busting.
83
83
  - `cache`: `true | false` if `true` (default) try to emit the file only if it was changed.
84
84
  - `showErrors`: `true | false` if `true` (default) errors details will be written into the html page.
85
85
  - `chunks`: Allows you to add only some chunks (e.g. only the unit-test chunk)
@@ -135,8 +135,8 @@ once in your plugins array:
135
135
  Writing Your Own Templates
136
136
  --------------------------
137
137
  If the default generated HTML doesn't meet your needs you can supply
138
- your own template. The easiest way is to use the `inject` option and pass a custom html file.
139
- The html-webpack-plugin will automatically inject all necessary css, js, manifest
138
+ your own template. The easiest way is to use the `template` option and pass a custom html file.
139
+ The html-webpack-plugin will automatically inject all necessary CSS, JS, manifest
140
140
  and favicon files into the markup.
141
141
 
142
142
  ```javascript
package/index.js CHANGED
@@ -63,7 +63,7 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
63
63
  });
64
64
 
65
65
  compiler.plugin('emit', function (compilation, callback) {
66
- var applyPluginsAsyncWaterfall = Promise.promisify(compilation.applyPluginsAsyncWaterfall, {context: compilation});
66
+ var applyPluginsAsyncWaterfall = self.applyPluginsAsyncWaterfall(compilation);
67
67
  // Get all chunks
68
68
  var chunks = self.filterChunks(compilation.getStats().toJson(), self.options.chunks, self.options.excludeChunks);
69
69
  // Sort chunks
@@ -93,7 +93,7 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
93
93
  if (self.options.favicon) {
94
94
  return self.addFileToAssets(self.options.favicon, compilation)
95
95
  .then(function (faviconBasename) {
96
- var publicPath = compilation.options.output.publicPath || '';
96
+ var publicPath = compilation.mainTemplate.getPublicPath({hash: compilation.hash}) || '';
97
97
  if (publicPath && publicPath.substr(-1) !== '/') {
98
98
  publicPath += '/';
99
99
  }
@@ -137,28 +137,33 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
137
137
  // Allow plugins to change the html before assets are injected
138
138
  .then(function (html) {
139
139
  var pluginArgs = {html: html, assets: assets, plugin: self, outputName: self.childCompilationOutputName};
140
- return applyPluginsAsyncWaterfall('html-webpack-plugin-before-html-processing', pluginArgs)
141
- .then(function () {
142
- return pluginArgs.html;
143
- });
140
+ return applyPluginsAsyncWaterfall('html-webpack-plugin-before-html-processing', pluginArgs);
144
141
  })
145
- .then(function (html) {
142
+ .then(function (result) {
143
+ var html = result.html;
144
+ var assets = result.assets;
145
+ var chunks = result.chunks;
146
146
  // Prepare script and link tags
147
147
  var assetTags = self.generateAssetTags(assets);
148
148
  var pluginArgs = {head: assetTags.head, body: assetTags.body, plugin: self, chunks: chunks, outputName: self.childCompilationOutputName};
149
149
  // Allow plugins to change the assetTag definitions
150
150
  return applyPluginsAsyncWaterfall('html-webpack-plugin-alter-asset-tags', pluginArgs)
151
- .then(function () {
151
+ .then(function (result) {
152
152
  // Add the stylesheets, scripts and so on to the resulting html
153
- return self.postProcessHtml(html, assets, { body: pluginArgs.body, head: pluginArgs.head });
153
+ return self.postProcessHtml(html, assets, { body: result.body, head: result.head })
154
+ .then(function (html) {
155
+ return _.extend(result, {html: html, assets: assets});
156
+ });
154
157
  });
155
158
  })
156
159
  // Allow plugins to change the html after assets are injected
157
- .then(function (html) {
160
+ .then(function (result) {
161
+ var html = result.html;
162
+ var assets = result.assets;
158
163
  var pluginArgs = {html: html, assets: assets, plugin: self, outputName: self.childCompilationOutputName};
159
164
  return applyPluginsAsyncWaterfall('html-webpack-plugin-after-html-processing', pluginArgs)
160
- .then(function () {
161
- return pluginArgs.html;
165
+ .then(function (result) {
166
+ return result.html;
162
167
  });
163
168
  })
164
169
  .catch(function (err) {
@@ -612,4 +617,21 @@ HtmlWebpackPlugin.prototype.getAssetFiles = function (assets) {
612
617
  return files;
613
618
  };
614
619
 
620
+ /**
621
+ * Helper to promisify compilation.applyPluginsAsyncWaterfall that returns
622
+ * a function that helps to merge given plugin arguments with processed ones
623
+ */
624
+ HtmlWebpackPlugin.prototype.applyPluginsAsyncWaterfall = function (compilation) {
625
+ var promisedApplyPluginsAsyncWaterfall = Promise.promisify(compilation.applyPluginsAsyncWaterfall, {context: compilation});
626
+ return function (eventName, pluginArgs) {
627
+ return promisedApplyPluginsAsyncWaterfall(eventName, pluginArgs)
628
+ .then(function (result) {
629
+ if (!result) {
630
+ compilation.warnings.push(new Error('Using html-webpack-plugin-after-html-processing without returning a result is deprecated.'));
631
+ }
632
+ return _.extend(pluginArgs, result);
633
+ });
634
+ };
635
+ };
636
+
615
637
  module.exports = HtmlWebpackPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "2.23.0",
3
+ "version": "2.24.0",
4
4
  "description": "Simplifies creation of HTML files to serve your webpack bundles",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -37,32 +37,32 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "appcache-webpack-plugin": "^1.3.0",
40
- "css-loader": "^0.23.1",
41
- "dir-compare": "1.0.1",
42
- "es6-promise": "^3.2.1",
40
+ "css-loader": "^0.25.0",
41
+ "dir-compare": "1.2.0",
42
+ "es6-promise": "^4.0.5",
43
43
  "extract-text-webpack-plugin": "^1.0.1",
44
44
  "file-loader": "^0.9.0",
45
- "html-loader": "^0.4.3",
45
+ "html-loader": "^0.4.4",
46
46
  "jade": "^1.11.0",
47
47
  "jade-loader": "^0.8.0",
48
- "jasmine": "^2.4.1",
48
+ "jasmine": "^2.5.2",
49
49
  "rimraf": "^2.5.4",
50
- "semistandard": "^8.0.0",
50
+ "semistandard": "8.0.0",
51
51
  "style-loader": "^0.13.1",
52
52
  "underscore-template-loader": "^0.7.3",
53
53
  "url-loader": "^0.5.7",
54
- "webpack": "^1.13.1",
54
+ "webpack": "^1.13.2",
55
55
  "webpack-recompilation-simulator": "^1.3.0"
56
56
  },
57
57
  "dependencies": {
58
- "bluebird": "^3.4.1",
59
- "html-minifier": "^3.0.2",
60
- "loader-utils": "^0.2.15",
61
- "lodash": "^4.14.2",
62
- "pretty-error": "^2.0.0",
58
+ "bluebird": "^3.4.6",
59
+ "html-minifier": "^3.1.0",
60
+ "loader-utils": "^0.2.16",
61
+ "lodash": "^4.16.4",
62
+ "pretty-error": "^2.0.2",
63
63
  "toposort": "^1.0.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "webpack": "*"
66
+ "webpack": "1 || ^2.1.0-beta"
67
67
  }
68
68
  }