diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 51f1a2ad..61d5c24d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,8 @@ name: CI -on: [push] + push: + branches: [main] + pull_request: + branches: [main] jobs: build: name: test Node ${{ matrix.node }} Webpack ${{ matrix.webpack }} ${{ matrix.os }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b582342..e85923e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ 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. +## [5.5.0](https://github.com/jantimon/html-webpack-plugin/compare/v5.4.0...v5.5.0) (2021-10-25) + + +### Features + +* Support type=module via scriptLoading option ([1e42625](https://github.com/jantimon/html-webpack-plugin/commit/1e4262528ff02a83e1fc7739b42472680fd205c2)), closes [#1663](https://github.com/jantimon/html-webpack-plugin/issues/1663) + ### [5.4.0](https://github.com/jantimon/html-webpack-plugin/compare/v5.3.2...v5.3.3) (2021-10-15) ### Features diff --git a/README.md b/README.md index a27337fb..8080d1ae 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Allowed values are as follows: |**`templateParameters`**|`{Boolean\|Object\|Function}`| `false`| Allows to overwrite the parameters used in the template - see [example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/template-parameters) | |**`inject`**|`{Boolean\|String}`|`true`|`true \|\| 'head' \|\| 'body' \|\| false` Inject all assets into the given `template` or `templateContent`. When passing `'body'` all javascript resources will be placed at the bottom of the body element. `'head'` will place the scripts in the head element. Passing `true` will add it to the head/body depending on the `scriptLoading` option. Passing `false` will disable automatic injections. - see the [inject:false example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/custom-insertion-position)| |**`publicPath`**|`{String\|'auto'}`|`'auto'`|The publicPath used for script and link tags| -|**`scriptLoading`**|`{'blocking'\|'defer'}`|`'defer'`| Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. | +|**`scriptLoading`**|`{'blocking'\|'defer'\|'module'}`|`'defer'`| Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. Setting to `'module'` adds attribute [`type="module"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html). This also implies "defer", since modules are automatically deferred. | |**`favicon`**|`{String}`|``|Adds the given favicon path to the output HTML| |**`meta`**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`| |**`base`**|`{Object\|String\|false}`|`false`|Inject a [`base`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag. E.g. `base: "https://example.com/path/page.html`| diff --git a/examples/javascript/dist/webpack-5/index.html b/examples/javascript/dist/webpack-5/index.html index 835e767f..535cd403 100644 --- a/examples/javascript/dist/webpack-5/index.html +++ b/examples/javascript/dist/webpack-5/index.html @@ -1 +1 @@ -Hello World from backend2021-10-09T14:25:52.580Z

Partial

\ No newline at end of file +Hello World from backend2021-10-25T11:10:42.875Z

Partial

\ No newline at end of file diff --git a/examples/pug-loader/dist/webpack-5/index.html b/examples/pug-loader/dist/webpack-5/index.html index 203953b6..5f9744d5 100644 --- a/examples/pug-loader/dist/webpack-5/index.html +++ b/examples/pug-loader/dist/webpack-5/index.html @@ -1 +1 @@ -pug demo
Current time

1999-01-01T05:00:00.000Z

\ No newline at end of file +pug demo
Current time

1998-12-31T23:00:00.000Z

\ No newline at end of file diff --git a/index.js b/index.js index 45f286ad..de9a6294 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ class HtmlWebpackPlugin { this.options = options; // Assert correct option spelling - assert(options.scriptLoading === 'defer' || options.scriptLoading === 'blocking', 'scriptLoading needs to be set to "defer" or "blocking'); + assert(options.scriptLoading === 'defer' || options.scriptLoading === 'blocking' || options.scriptLoading === 'module', 'scriptLoading needs to be set to "defer", "blocking" or "module"'); assert(options.inject === true || options.inject === false || options.inject === 'head' || options.inject === 'body', 'inject needs to be set to true, false, "head" or "body'); // Default metaOptions if no template is provided @@ -741,7 +741,8 @@ function hookIntoCompiler (compiler, options, plugin) { voidTag: false, meta: { plugin: 'html-webpack-plugin' }, attributes: { - defer: options.scriptLoading !== 'blocking', + defer: options.scriptLoading === 'defer', + type: options.scriptLoading === 'module' ? 'module' : undefined, src: scriptAsset } })); diff --git a/package.json b/package.json index 6845ff17..bc3c6b49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-webpack-plugin", - "version": "5.4.0", + "version": "5.5.0", "license": "MIT", "description": "Simplifies creation of HTML files to serve your webpack bundles", "author": "Jan Nicklas (https://github.com/jantimon)", @@ -32,9 +32,9 @@ "commitizen": "^4.2.4", "css-loader": "5.0.1", "cz-conventional-changelog": "2.1.0", - "dir-compare": "1.7.2", + "dir-compare": "^3.3.0", "html-loader": "2.1.1", - "jest": "26.5.3", + "jest": "^27.2.5", "mini-css-extract-plugin": "^1.6.0", "pug": "3.0.2", "pug-loader": "2.4.0", @@ -52,7 +52,7 @@ "@types/html-minifier-terser": "^6.0.0", "html-minifier-terser": "^6.0.2", "lodash": "^4.17.21", - "pretty-error": "^3.0.4", + "pretty-error": "^4.0.0", "tapable": "^2.0.0" }, "peerDependencies": { diff --git a/spec/basic.spec.js b/spec/basic.spec.js index 794e14c6..b325f7cd 100644 --- a/spec/basic.spec.js +++ b/spec/basic.spec.js @@ -2526,6 +2526,20 @@ describe('HtmlWebpackPlugin', () => { }, [/