Skip to content

Commit 90f7f91

Browse files
authored
test: universal publicPath auto (#20508)
1 parent e01b562 commit 90f7f91

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

test/configCases/target/universal-public-path/image.png

Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import img from "./image.png";
2+
3+
it("should resolve public path automatically in universal target", () => {
4+
expect(img).toMatch(/^(https?|file):\/\//);
5+
expect(img).toMatch(/[a-f0-9]+\.png$/);
6+
expect(img.startsWith(__webpack_public_path__)).toBe(true);
7+
});
8+
9+
it("should have correct __webpack_public_path__", () => {
10+
expect(__webpack_public_path__).toMatch(/^(https?|file):\/\//);
11+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"use strict";
2+
3+
module.exports = {
4+
findBundle(i, options) {
5+
return ["main.mjs"];
6+
}
7+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"use strict";
2+
3+
/** @type {import("../../../../").Configuration[]} */
4+
module.exports = [
5+
{
6+
name: "universal-esm",
7+
target: ["web", "node"],
8+
mode: "development",
9+
devtool: false,
10+
output: {
11+
publicPath: "auto",
12+
module: true,
13+
filename: "[name].mjs"
14+
},
15+
experiments: {
16+
outputModule: true
17+
},
18+
module: {
19+
rules: [
20+
{
21+
test: /\.png$/,
22+
type: "asset/resource"
23+
}
24+
]
25+
}
26+
}
27+
];

0 commit comments

Comments
 (0)