Skip to content

Commit 58c6b74

Browse files
fix: prefetch and preload runtime generation (#1116)
1 parent 00cdedb commit 58c6b74

File tree

6 files changed

+33
-2
lines changed

6 files changed

+33
-2
lines changed

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ class MiniCssExtractPlugin {
11231123
])
11241124
: "// no hmr",
11251125
"",
1126-
withPrefetch && hasCssMatcher !== false
1126+
withPrefetch && withLoading && hasCssMatcher !== false
11271127
? `${
11281128
RuntimeGlobals.prefetchChunkHandlers
11291129
}.miniCss = ${runtimeTemplate.basicFunction("chunkId", [
@@ -1159,7 +1159,7 @@ class MiniCssExtractPlugin {
11591159
])};`
11601160
: "// no prefetching",
11611161
"",
1162-
withPreload && hasCssMatcher !== false
1162+
withPreload && withLoading && hasCssMatcher !== false
11631163
? `${
11641164
RuntimeGlobals.preloadChunkHandlers
11651165
}.miniCss = ${runtimeTemplate.basicFunction("chunkId", [

test/cases/prefetch-preload-hmr/a.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.a {
2+
color: red;
3+
}

test/cases/prefetch-preload-hmr/b.js

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.a {
2+
color: red;
3+
}
4+
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import "./a.css";
2+
3+
import(/* webpackPrefetch: true */ "./b");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import webpack from "webpack";
2+
3+
import Self from "../../../src";
4+
5+
module.exports = {
6+
entry: "./index.js",
7+
module: {
8+
rules: [
9+
{
10+
test: /\.css$/,
11+
use: [Self.loader, "css-loader"],
12+
},
13+
],
14+
},
15+
plugins: [
16+
new Self({
17+
filename: "[name].css",
18+
}),
19+
new webpack.HotModuleReplacementPlugin(),
20+
],
21+
};

0 commit comments

Comments
 (0)