@@ -20,8 +20,6 @@ const {
20
20
util : { createHash } ,
21
21
} = webpack ;
22
22
23
- const isWebpack4 = webpackVersion [ 0 ] === '4' ;
24
-
25
23
const pluginName = 'mini-css-extract-plugin' ;
26
24
27
25
const REGEXP_CHUNKHASH = / \[ c h u n k h a s h (?: : ( \d + ) ) ? \] / i;
@@ -97,16 +95,12 @@ class MiniCssExtractPlugin {
97
95
this . options . chunkFilename = '[id].css' ;
98
96
}
99
97
}
100
-
101
- if ( ! isWebpack4 && 'hmr' in this . options ) {
102
- throw new Error (
103
- "The 'hmr' option doesn't exist for the mini-css-extract-plugin when using webpack 5 (it's automatically determined)"
104
- ) ;
105
- }
106
98
}
107
99
108
100
/** @param {import("webpack").Compiler } compiler */
109
101
apply ( compiler ) {
102
+ const isWebpack4 = compiler . webpack ? false : webpackVersion [ 0 ] === '4' ;
103
+
110
104
if ( ! isWebpack4 ) {
111
105
const { splitChunks } = compiler . options . optimization ;
112
106
if ( splitChunks ) {
@@ -200,7 +194,9 @@ class MiniCssExtractPlugin {
200
194
201
195
// We don't need hot update chunks for css
202
196
// We will use the real asset instead to update
203
- if ( chunk instanceof webpack . HotUpdateChunk ) return ;
197
+ if ( chunk instanceof webpack . HotUpdateChunk ) {
198
+ return ;
199
+ }
204
200
205
201
const renderedModules = Array . from (
206
202
this . getChunkModules ( chunk , chunkGraph )
@@ -439,7 +435,10 @@ class MiniCssExtractPlugin {
439
435
} else {
440
436
const enabledChunks = new WeakSet ( ) ;
441
437
const handler = ( chunk , set ) => {
442
- if ( enabledChunks . has ( chunk ) ) return ;
438
+ if ( enabledChunks . has ( chunk ) ) {
439
+ return ;
440
+ }
441
+
443
442
enabledChunks . add ( chunk ) ;
444
443
445
444
// eslint-disable-next-line global-require
0 commit comments