Skip to content

Commit 179667c

Browse files
committed
fix: compilation fails if used the integrity option with the publicPath as an external URL
1 parent 0a6b81b commit 179667c

File tree

21 files changed

+155
-8
lines changed

21 files changed

+155
-8
lines changed

CHANGELOG.md

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

3+
## 4.15.3 (2025-01-27)
4+
5+
- fix: compilation fails if used the integrity option with the publicPath as an external URL
6+
- fix: improve error messages inc. error stack if async processes fail
7+
38
## 4.15.2 (2025-01-22)
49

510
- fix: unpredictably Webpack compilation fails after a random number of runs, #143

package.json

Lines changed: 1 addition & 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.2",
3+
"version": "4.15.3",
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",

src/Plugin/AssetCompiler.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,10 @@ class AssetCompiler {
17341734
// }
17351735

17361736
if (this.exceptions.size > 0) {
1737-
const messages = Array.from(this.exceptions).join('\n\n');
1737+
const messages = Array.from(this.exceptions)
1738+
.map((error) => (error.stack ? error.stack : error.toString()))
1739+
.reduce((previousValue, currentValue) => previousValue + currentValue, '');
1740+
17381741
this.exceptions.clear();
17391742
throw new Error(messages);
17401743
}

src/Plugin/Collection.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,14 @@ class Collection {
992992
if (hasIntegrity && !inline) {
993993
// path to asset relative by output.path
994994
let pathname = asset.assetFile;
995+
995996
if (this.pluginOption.isAutoPublicPath()) {
996997
pathname = path.join(entryDirname, pathname);
997998
} else if (this.pluginOption.isRootPublicPath()) {
998999
pathname = pathname.slice(1);
1000+
} else if (this.pluginOption.isUrlPublicPath()) {
1001+
let publicPath = this.pluginOption.getPublicPath();
1002+
pathname = pathname.replace(publicPath, '');
9991003
}
10001004

10011005
const assetContent = compilation.assets[pathname].source();

src/Plugin/Option.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ class Option {
320320
}
321321

322322
this.autoPublicPath = false;
323-
this.isUrlPublicPath = false;
323+
this.urlPublicPath = false;
324324
this.rootPublicPath = false;
325325
this.isRelativePublicPath = false;
326326
this.webpackPublicPath = publicPath;
327327

328328
if (publicPath === 'auto') {
329329
this.autoPublicPath = true;
330330
} else if (/^(\/\/|https?:\/\/)/i.test(publicPath)) {
331-
this.isUrlPublicPath = true;
331+
this.urlPublicPath = true;
332332
} else if (!publicPath.startsWith('/')) {
333333
this.isRelativePublicPath = true;
334334
} else if (publicPath.startsWith('/')) {
@@ -508,6 +508,10 @@ class Option {
508508
return this.rootPublicPath === true;
509509
}
510510

511+
isUrlPublicPath() {
512+
return this.urlPublicPath === true;
513+
}
514+
511515
hasPostprocess() {
512516
return this.#process.has('postprocess');
513517
}
@@ -695,7 +699,7 @@ class Option {
695699
return isWin ? pathToPosix(outputFilename) : outputFilename;
696700
}
697701

698-
if (this.isUrlPublicPath) {
702+
if (this.isUrlPublicPath()) {
699703
const url = new URL(assetFile, this.webpackPublicPath);
700704
return url.href;
701705
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h1 {
2+
color: red;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h2 {
2+
color: green;
3+
}
1.22 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log(">> main");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log(">> ignore integrity");

0 commit comments

Comments
 (0)