diff --git a/src/index.js b/src/index.js index 7fc94b01..b7caa4bb 100644 --- a/src/index.js +++ b/src/index.js @@ -1123,7 +1123,7 @@ class MiniCssExtractPlugin { ]) : "// no hmr", "", - withPrefetch && hasCssMatcher !== false + withPrefetch && withLoading && hasCssMatcher !== false ? `${ RuntimeGlobals.prefetchChunkHandlers }.miniCss = ${runtimeTemplate.basicFunction("chunkId", [ @@ -1159,7 +1159,7 @@ class MiniCssExtractPlugin { ])};` : "// no prefetching", "", - withPreload && hasCssMatcher !== false + withPreload && withLoading && hasCssMatcher !== false ? `${ RuntimeGlobals.preloadChunkHandlers }.miniCss = ${runtimeTemplate.basicFunction("chunkId", [ diff --git a/test/cases/prefetch-preload-hmr/a.css b/test/cases/prefetch-preload-hmr/a.css new file mode 100644 index 00000000..5451a331 --- /dev/null +++ b/test/cases/prefetch-preload-hmr/a.css @@ -0,0 +1,3 @@ +.a { + color: red; +} diff --git a/test/cases/prefetch-preload-hmr/b.js b/test/cases/prefetch-preload-hmr/b.js new file mode 100644 index 00000000..e69de29b diff --git a/test/cases/prefetch-preload-hmr/expected/main.css b/test/cases/prefetch-preload-hmr/expected/main.css new file mode 100644 index 00000000..98f445d8 --- /dev/null +++ b/test/cases/prefetch-preload-hmr/expected/main.css @@ -0,0 +1,4 @@ +.a { + color: red; +} + diff --git a/test/cases/prefetch-preload-hmr/index.js b/test/cases/prefetch-preload-hmr/index.js new file mode 100644 index 00000000..e615a5ec --- /dev/null +++ b/test/cases/prefetch-preload-hmr/index.js @@ -0,0 +1,3 @@ +import "./a.css"; + +import(/* webpackPrefetch: true */ "./b"); diff --git a/test/cases/prefetch-preload-hmr/webpack.config.js b/test/cases/prefetch-preload-hmr/webpack.config.js new file mode 100644 index 00000000..d07a9495 --- /dev/null +++ b/test/cases/prefetch-preload-hmr/webpack.config.js @@ -0,0 +1,21 @@ +import webpack from "webpack"; + +import Self from "../../../src"; + +module.exports = { + entry: "./index.js", + module: { + rules: [ + { + test: /\.css$/, + use: [Self.loader, "css-loader"], + }, + ], + }, + plugins: [ + new Self({ + filename: "[name].css", + }), + new webpack.HotModuleReplacementPlugin(), + ], +};