Skip to content

Commit 4a165dc

Browse files
committed
fix: improve handling exceptions in integrity module, #143
1 parent 1799354 commit 4a165dc

38 files changed

Lines changed: 388 additions & 45 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.15.1 (2025-01-21)
4+
5+
- fix: improve the handling exceptions in the integrity module, #143
6+
37
## 4.15.0 (2025-01-21)
48

59
- chore: bump from beta to release v4.15.0

package-lock.json

Lines changed: 95 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-bundler-webpack-plugin",
3-
"version": "4.15.0",
3+
"version": "4.15.1",
44
"description": "Generates complete single-page or multi-page website from source assets. Build-in support for Markdown, Eta, EJS, Handlebars, Nunjucks, Pug. Alternative to html-webpack-plugin.",
55
"keywords": [
66
"html",
@@ -177,6 +177,7 @@
177177
"handlebars-layouts": "^3.1.4",
178178
"html-minimizer-webpack-plugin": "^5.0.0",
179179
"github-markdown-css": "^5.8.1",
180+
"image-minimizer-webpack-plugin": "^4.1.3",
180181
"jest": "^29.7.0",
181182
"liquidjs": "^10.18.0",
182183
"markdown-it": "^14.1.0",

src/Plugin/Extras/Integrity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class Integrity {
125125
for (const chunk of this.compilation.chunks) {
126126
const chunkFile = [...chunk.files][0];
127127

128-
if (!(typeof chunk.runtime === 'string') || !chunkFile.endsWith('.js')) {
128+
if (!chunkFile || !(typeof chunk.runtime === 'string') || !chunkFile.endsWith('.js')) {
129129
continue;
130130
}
131131

test/cases/_exceptions/msg-exception-import-css-wo-head/expected/assets/css/main.eb387a9e.css

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/cases/_exceptions/msg-exception-import-css-wo-head/expected/assets/js/main.761e0246.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/cases/_exceptions/msg-exception-import-css-wo-head/expected/index.html

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Test</title>
5+
<link href="./style.css" rel="stylesheet">
6+
</head>
7+
<body>
8+
<h1>Hello World!</h1>
9+
</body>
10+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h1 {
2+
color: orangered;
3+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const path = require('path');
2+
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin');
3+
4+
module.exports = {
5+
mode: 'production',
6+
output: {
7+
crossOriginLoading: 'anonymous',
8+
},
9+
plugins: [
10+
new HtmlBundlerPlugin({
11+
entry: {
12+
index: './src/index.html',
13+
},
14+
css: {
15+
filename: 'css/[name].[contenthash:8].css',
16+
},
17+
integrity: true, // fix: cause own error and masks original error
18+
}),
19+
],
20+
module: {
21+
// disable the CSS rule to simulate the exception,
22+
// fixed: the original error what in will not be displayed because the `integrity` module cause own error
23+
// rules: [
24+
// {
25+
// test: /\.(css)$/,
26+
// use: ['css-loader'],
27+
// },
28+
// ],
29+
},
30+
};

0 commit comments

Comments
 (0)