html-webpack-plugin 4.0.0 → 4.0.4

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
@@ -2,6 +2,42 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [4.0.4](https://github.com/jantimon/html-webpack-plugin/compare/v4.0.3...v4.0.4) (2020-04-01)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * Fix querystring encoding ([#1386](https://github.com/jantimon/html-webpack-plugin/issues/1386)) ([4f48a39](https://github.com/jantimon/html-webpack-plugin/commit/4f48a39e5738a5d431be2bec39c1b1f0de800d57)), closes [#1355](https://github.com/jantimon/html-webpack-plugin/issues/1355)
11
+
12
+
13
+
14
+ ## [4.0.3](https://github.com/jantimon/html-webpack-plugin/compare/v4.0.2...v4.0.3) (2020-03-28)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * add webpack, tapable and html-minifier-terser as dependencies because of types.d.ts ([238da81](https://github.com/jantimon/html-webpack-plugin/commit/238da8123950f87267954fd448f3e6b0fb1ead17))
20
+
21
+
22
+
23
+ ## [4.0.2](https://github.com/jantimon/html-webpack-plugin/compare/v4.0.1...v4.0.2) (2020-03-26)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * don't remove trailing slashes from self closing tags by default ([2281e4b](https://github.com/jantimon/html-webpack-plugin/commit/2281e4bfda9b91c4a83d63bfc8df8372d1e6ae9e))
29
+
30
+
31
+
32
+ ## [4.0.1](https://github.com/jantimon/html-webpack-plugin/compare/v4.0.0...v4.0.1) (2020-03-23)
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * update typedefs to match with html-minifier-terser ([2698c7e](https://github.com/jantimon/html-webpack-plugin/commit/2698c7e45a7f12113a07b256dc400ec89666130d))
38
+
39
+
40
+
5
41
  # [4.0.0](https://github.com/jantimon/html-webpack-plugin/compare/v3.2.0...v4.0.0) (2020-03-23)
6
42
 
7
43
  The summary can be found in the [**release blog post**](https://dev.to/jantimon/html-webpack-plugin-4-has-been-released-125d).
package/README.md CHANGED
@@ -19,17 +19,7 @@
19
19
  <p>Plugin that simplifies creation of HTML files to serve your bundles</p>
20
20
  </div>
21
21
 
22
- <h2 align="center">Install Beta</h2>
23
-
24
- ```bash
25
- npm i --save-dev html-webpack-plugin@next
26
- ```
27
-
28
- ```bash
29
- yarn add --dev html-webpack-plugin@next
30
- ```
31
-
32
- <h2 align="center">Install Stable</h2>
22
+ <h2 align="center">Install</h2>
33
23
 
34
24
  ```bash
35
25
  npm i --save-dev html-webpack-plugin
@@ -291,7 +281,7 @@ The following variables are available in the template:
291
281
  - `webpackConfig`: the webpack configuration that was used for this compilation. This
292
282
  can be used, for example, to get the `publicPath` (`webpackConfig.output.publicPath`).
293
283
 
294
- - `compilation`: the webpack [compilation](https://webpack.js.org/api/compilation/) object.
284
+ - `compilation`: the webpack [compilation object](https://webpack.js.org/api/compilation-object/).
295
285
  This can be used, for example, to get the contents of processed assets and inline them
296
286
  directly in the page, through `compilation.assets[...].source()`
297
287
  (see [the inline template example](examples/inline/template.pug)).
package/index.js CHANGED
@@ -115,10 +115,11 @@ class HtmlWebpackPlugin {
115
115
 
116
116
  const minify = this.options.minify;
117
117
  if (minify === true || (minify === 'auto' && isProductionLikeMode)) {
118
- /** @type { import('html-minifier').Options } */
118
+ /** @type { import('html-minifier-terser').Options } */
119
119
  this.options.minify = {
120
- // https://github.com/kangax/html-minifier#options-quick-reference
120
+ // https://www.npmjs.com/package/html-minifier-terser#options-quick-reference
121
121
  collapseWhitespace: true,
122
+ keepClosingSlash: true,
122
123
  removeComments: true,
123
124
  removeRedundantAttributes: true,
124
125
  removeScriptTypeAttributes: true,
@@ -938,10 +939,35 @@ class HtmlWebpackPlugin {
938
939
  * Encode each path component using `encodeURIComponent` as files can contain characters
939
940
  * which needs special encoding in URLs like `+ `.
940
941
  *
942
+ * Valid filesystem characters which need to be encoded for urls:
943
+ *
944
+ * # pound, % percent, & ampersand, { left curly bracket, } right curly bracket,
945
+ * \ back slash, < left angle bracket, > right angle bracket, * asterisk, ? question mark,
946
+ * blank spaces, $ dollar sign, ! exclamation point, ' single quotes, " double quotes,
947
+ * : colon, @ at sign, + plus sign, ` backtick, | pipe, = equal sign
948
+ *
949
+ * However the query string must not be encoded:
950
+ *
951
+ * fo:demonstration-path/very fancy+name.js?path=/home?value=abc&value=def#zzz
952
+ * ^ ^ ^ ^ ^ ^ ^ ^^ ^ ^ ^ ^ ^
953
+ * | | | | | | | || | | | | |
954
+ * encoded | | encoded | | || | | | | |
955
+ * ignored ignored ignored ignored ignored
956
+ *
941
957
  * @param {string} filePath
942
958
  */
943
959
  urlencodePath (filePath) {
944
- return filePath.split('/').map(encodeURIComponent).join('/');
960
+ // People use the filepath in quite unexpected ways.
961
+ // Try to extract the first querystring of the url:
962
+ //
963
+ // some+path/demo.html?value=abc?def
964
+ //
965
+ const queryStringStart = filePath.indexOf('?');
966
+ const urlPath = queryStringStart === -1 ? filePath : filePath.substr(0, queryStringStart);
967
+ const queryString = filePath.substr(urlPath.length);
968
+ // Encode all parts except '/' which are not part of the querystring:
969
+ const encodedUrlPath = urlPath.split('/').map(encodeURIComponent).join('/');
970
+ return encodedUrlPath + queryString;
945
971
  }
946
972
 
947
973
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "4.0.0",
3
+ "version": "4.0.4",
4
4
  "license": "MIT",
5
5
  "description": "Simplifies creation of HTML files to serve your webpack bundles",
6
6
  "author": "Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)",
@@ -28,10 +28,8 @@
28
28
  ]
29
29
  },
30
30
  "devDependencies": {
31
- "@types/html-minifier": "3.5.3",
32
31
  "@types/loader-utils": "1.1.3",
33
32
  "@types/node": "11.13.9",
34
- "@types/tapable": "1.0.4",
35
33
  "appcache-webpack-plugin": "1.4.0",
36
34
  "commitizen": "4.0.3",
37
35
  "css-loader": "2.1.1",
@@ -52,6 +50,9 @@
52
50
  "webpack-recompilation-simulator": "3.0.0"
53
51
  },
54
52
  "dependencies": {
53
+ "@types/html-minifier-terser": "^5.0.0",
54
+ "@types/tapable": "^1.0.5",
55
+ "@types/webpack": "^4.41.8",
55
56
  "html-minifier-terser": "^5.0.1",
56
57
  "loader-utils": "^1.2.3",
57
58
  "lodash": "^4.17.15",
package/typings.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AsyncSeriesWaterfallHook } from "tapable";
2
2
  import { Compiler, compilation } from 'webpack';
3
- import { Options as HtmlMinifierOptions } from "html-minifier";
3
+ import { Options as HtmlMinifierOptions } from "html-minifier-terser";
4
4
 
5
5
  export = HtmlWebpackPlugin;
6
6