Skip to content

Commit 5b8ab7e

Browse files
fix: bloated runtime
1 parent 05e2951 commit 5b8ab7e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,15 @@ class MiniCssExtractPlugin {
477477
MODULE_TYPE,
478478
'mini-css',
479479
`${webpack.RuntimeGlobals.require}.miniCssF`,
480-
(referencedChunk) =>
481-
referencedChunk.canBeInitial()
480+
(referencedChunk) => {
481+
if (!referencedChunk.contentHash[MODULE_TYPE]) {
482+
return '';
483+
}
484+
485+
return referencedChunk.canBeInitial()
482486
? this.options.filename
483-
: this.options.chunkFilename,
487+
: this.options.chunkFilename;
488+
},
484489
true
485490
)
486491
);

test/cases/runtime/expected/webpack-5/runtime~main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
/******/ // This function allow to reference all chunks
102102
/******/ __webpack_require__.miniCssF = (chunkId) => {
103103
/******/ // return url for filenames based on template
104-
/******/ return "" + ({"0":"main","1":"runtime~main"}[chunkId] || chunkId) + "." + {"0":"a7263f8f763dcf4051bc"}[chunkId] + ".css";
104+
/******/ return "" + "main" + "." + "a7263f8f763dcf4051bc" + ".css";
105105
/******/ };
106106
/******/ })();
107107
/******/

0 commit comments

Comments
 (0)