html-webpack-plugin 2.25.0 → 2.28.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,23 @@
1
1
  Change History
2
2
  ==============
3
3
 
4
+ v2.28.0
5
+ ---
6
+ * Backport 3.x void tag for plugin authors
7
+
8
+ v2.27.1
9
+ ---
10
+ * Revert 2.25.0 loader resolving
11
+
12
+ v2.27.0
13
+ ---
14
+ * Fix a chunksorter webpack 2 issue (#569)
15
+ * Fix template path resolving(#542)
16
+
17
+ v2.26.0
18
+ ---
19
+ * Allow plugins to add attributes without values to the `<script>` and `<link>` tags
20
+
4
21
  v2.25.0
5
22
  ---
6
23
  * Clearer loader output
package/README.md CHANGED
@@ -29,7 +29,11 @@ There are already some really powerful plugins which can be integrated with zero
29
29
  * [favicons-webpack-plugin](https://github.com/jantimon/favicons-webpack-plugin) which generates favicons and icons for iOS, Android and desktop browsers
30
30
  * [html-webpack-harddisk-plugin](https://github.com/jantimon/html-webpack-harddisk-plugin)
31
31
  * [html-webpack-inline-source-plugin](https://github.com/DustinJackson/html-webpack-inline-source-plugin) to inline your assets in the resulting HTML file
32
- * [html-webpack-exclude-assets-plugin](https://github.com/jamesjieye/html-webpack-exclude-assets-plugin) for excluding assets using regular expressions
32
+ * [html-webpack-exclude-assets-plugin](https://github.com/jamesjieye/html-webpack-exclude-assets-plugin) for excluding assets using regular expressions
33
+ * [html-webpack-include-assets-plugin](https://github.com/jharris4/html-webpack-include-assets-plugin) for including lists of js or css file paths (such as those copied by the copy-webpack-plugin).
34
+ * [script-ext-html-webpack-plugin](https://github.com/numical/script-ext-html-webpack-plugin) to add `async`, `defer` or `module` attributes to your`<script>` elements, or even in-line them
35
+ * [style-ext-html-webpack-plugin](https://github.com/numical/style-ext-html-webpack-plugin) to convert your `<link>`s to external stylesheets into `<style>` elements containing internal CSS
36
+ * [resource-hints-webpack-plugin](https://github.com/jantimon/resource-hints-webpack-plugin) to add resource hints for faster initial page loads
33
37
 
34
38
  Basic Usage
35
39
  -----------
@@ -308,6 +312,8 @@ Note that the callback must be passed the htmlPluginData in order to pass this o
308
312
  You're free to contribute to this project by submitting [issues](https://github.com/ampedandwired/html-webpack-plugin/issues) and/or [pull requests](https://github.com/ampedandwired/html-webpack-plugin/pulls). This project is test-driven, so keep in mind that every change and new feature should be covered by tests.
309
313
  This project uses the [semistandard code style](https://github.com/Flet/semistandard).
310
314
 
315
+ Before running the tests, make sure to execute `yarn link` and `yarn link html-webpack-plugin` (or the npm variant of this).
316
+
311
317
  # License
312
318
 
313
319
  This project is licensed under [MIT](https://github.com/ampedandwired/html-webpack-plugin/blob/master/LICENSE).
package/index.js CHANGED
@@ -233,6 +233,9 @@ HtmlWebpackPlugin.prototype.evaluateCompilationResult = function (compilation, s
233
233
  } catch (e) {
234
234
  return Promise.reject(e);
235
235
  }
236
+ if (typeof newSource === 'object' && newSource.__esModule && newSource.default) {
237
+ newSource = newSource.default;
238
+ }
236
239
  return typeof newSource === 'string' || typeof newSource === 'function'
237
240
  ? Promise.resolve(newSource)
238
241
  : Promise.reject('The loader "' + this.options.template + '" didn\'t return html.');
@@ -581,12 +584,22 @@ HtmlWebpackPlugin.prototype.appendHash = function (url, hash) {
581
584
  * Turn a tag definition into a html string
582
585
  */
583
586
  HtmlWebpackPlugin.prototype.createHtmlTag = function (tagDefinition) {
584
- var attributes = Object.keys(tagDefinition.attributes || {}).map(function (attributeName) {
585
- return attributeName + '="' + tagDefinition.attributes[attributeName] + '"';
586
- });
587
- return '<' + [tagDefinition.tagName].concat(attributes).join(' ') + (tagDefinition.selfClosingTag ? '/' : '') + '>' +
587
+ var attributes = Object.keys(tagDefinition.attributes || {})
588
+ .filter(function (attributeName) {
589
+ return tagDefinition.attributes[attributeName] !== false;
590
+ })
591
+ .map(function (attributeName) {
592
+ if (tagDefinition.attributes[attributeName] === true) {
593
+ return attributeName;
594
+ }
595
+ return attributeName + '="' + tagDefinition.attributes[attributeName] + '"';
596
+ });
597
+ // Backport of 3.x void tag definition
598
+ var voidTag = tagDefinition.voidTag !== undefined ? tagDefinition.voidTag : !tagDefinition.closeTag;
599
+ var selfClosingTag = tagDefinition.voidTag !== undefined ? tagDefinition.voidTag && this.options.xhtml : tagDefinition.selfClosingTag;
600
+ return '<' + [tagDefinition.tagName].concat(attributes).join(' ') + (selfClosingTag ? '/' : '') + '>' +
588
601
  (tagDefinition.innerHTML || '') +
589
- (tagDefinition.closeTag ? '</' + tagDefinition.tagName + '>' : '');
602
+ (voidTag ? '' : '</' + tagDefinition.tagName + '>');
590
603
  };
591
604
 
592
605
  /**
@@ -595,11 +608,11 @@ HtmlWebpackPlugin.prototype.createHtmlTag = function (tagDefinition) {
595
608
  HtmlWebpackPlugin.prototype.getFullTemplatePath = function (template, context) {
596
609
  // If the template doesn't use a loader use the lodash template loader
597
610
  if (template.indexOf('!') === -1) {
598
- template = 'html-webpack-plugin/lib/loader.js!' + path.resolve(context, template);
611
+ template = require.resolve('./lib/loader.js') + '!' + path.resolve(context, template);
599
612
  }
600
613
  // Resolve template path
601
614
  return template.replace(
602
- /([!])([^\/\\][^!\?]+|[^\/\\!?])($|\?.+$)/,
615
+ /([!])([^/\\][^!?]+|[^/\\!?])($|\?[^!?\n]+$)/,
603
616
  function (match, prefix, filepath, postfix) {
604
617
  return prefix + path.resolve(filepath) + postfix;
605
618
  });
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var toposort = require('toposort');
4
+ var _ = require('lodash');
4
5
 
5
6
  /*
6
7
  Sorts dependencies between chunks by their "parents" attribute.
@@ -40,7 +41,8 @@ module.exports.dependency = function (chunks) {
40
41
  if (chunk.parents) {
41
42
  // Add an edge for each parent (parent -> child)
42
43
  chunk.parents.forEach(function (parentId) {
43
- var parentChunk = nodeMap[parentId];
44
+ // webpack2 chunk.parents are chunks instead of string id(s)
45
+ var parentChunk = _.isObject(parentId) ? parentId : nodeMap[parentId];
44
46
  // If the parent chunk does not exist (e.g. because of an excluded chunk)
45
47
  // we ignore that parent
46
48
  if (parentChunk) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "2.25.0",
3
+ "version": "2.28.0",
4
4
  "description": "Simplifies creation of HTML files to serve your webpack bundles",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -37,8 +37,8 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "appcache-webpack-plugin": "^1.3.0",
40
- "css-loader": "^0.25.0",
41
- "dir-compare": "1.2.0",
40
+ "css-loader": "^0.26.1",
41
+ "dir-compare": "1.3.0",
42
42
  "es6-promise": "^4.0.5",
43
43
  "extract-text-webpack-plugin": "^1.0.1",
44
44
  "file-loader": "^0.9.0",
@@ -51,14 +51,14 @@
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.2",
54
+ "webpack": "^1.14.0",
55
55
  "webpack-recompilation-simulator": "^1.3.0"
56
56
  },
57
57
  "dependencies": {
58
- "bluebird": "^3.4.6",
59
- "html-minifier": "^3.1.0",
58
+ "bluebird": "^3.4.7",
59
+ "html-minifier": "^3.2.3",
60
60
  "loader-utils": "^0.2.16",
61
- "lodash": "^4.16.4",
61
+ "lodash": "^4.17.3",
62
62
  "pretty-error": "^2.0.2",
63
63
  "toposort": "^1.0.0"
64
64
  },