@@ -10,7 +10,7 @@ const {
10
10
util : { createHash } ,
11
11
} = webpack ;
12
12
13
- const NS = path . dirname ( fs . realpathSync ( __filename ) ) ;
13
+ const MODULE_TYPE = 'css/mini-extract' ;
14
14
15
15
const pluginName = 'mini-css-extract-plugin' ;
16
16
@@ -44,7 +44,7 @@ class CssDependencyTemplate {
44
44
45
45
class CssModule extends webpack . Module {
46
46
constructor ( dependency ) {
47
- super ( NS , dependency . context ) ;
47
+ super ( MODULE_TYPE , dependency . context ) ;
48
48
this . _identifier = dependency . identifier ;
49
49
this . _identifierIndex = dependency . identifierIndex ;
50
50
this . content = dependency . content ;
@@ -141,7 +141,7 @@ class MiniCssExtractPlugin {
141
141
compilation . hooks . normalModuleLoader . tap ( pluginName , ( lc , m ) => {
142
142
const loaderContext = lc ;
143
143
const module = m ;
144
- loaderContext [ NS ] = ( content ) => {
144
+ loaderContext [ MODULE_TYPE ] = ( content ) => {
145
145
if ( ! Array . isArray ( content ) && content != null ) {
146
146
throw new Error (
147
147
`Exported value was not extracted as an array: ${ JSON . stringify (
@@ -169,7 +169,7 @@ class MiniCssExtractPlugin {
169
169
pluginName ,
170
170
( result , { chunk } ) => {
171
171
const renderedModules = Array . from ( chunk . modulesIterable ) . filter (
172
- ( module ) => module . type === NS
172
+ ( module ) => module . type === MODULE_TYPE
173
173
) ;
174
174
if ( renderedModules . length > 0 ) {
175
175
result . push ( {
@@ -183,10 +183,10 @@ class MiniCssExtractPlugin {
183
183
filenameTemplate : this . options . filename ,
184
184
pathOptions : {
185
185
chunk,
186
- contentHashType : NS ,
186
+ contentHashType : MODULE_TYPE ,
187
187
} ,
188
188
identifier : `${ pluginName } .${ chunk . id } ` ,
189
- hash : chunk . contentHash [ NS ] ,
189
+ hash : chunk . contentHash [ MODULE_TYPE ] ,
190
190
} ) ;
191
191
}
192
192
}
@@ -195,7 +195,7 @@ class MiniCssExtractPlugin {
195
195
pluginName ,
196
196
( result , { chunk } ) => {
197
197
const renderedModules = Array . from ( chunk . modulesIterable ) . filter (
198
- ( module ) => module . type === NS
198
+ ( module ) => module . type === MODULE_TYPE
199
199
) ;
200
200
if ( renderedModules . length > 0 ) {
201
201
result . push ( {
@@ -209,10 +209,10 @@ class MiniCssExtractPlugin {
209
209
filenameTemplate : this . options . chunkFilename ,
210
210
pathOptions : {
211
211
chunk,
212
- contentHashType : NS ,
212
+ contentHashType : MODULE_TYPE ,
213
213
} ,
214
214
identifier : `${ pluginName } .${ chunk . id } ` ,
215
- hash : chunk . contentHash [ NS ] ,
215
+ hash : chunk . contentHash [ MODULE_TYPE ] ,
216
216
} ) ;
217
217
}
218
218
}
@@ -226,7 +226,7 @@ class MiniCssExtractPlugin {
226
226
}
227
227
if ( REGEXP_CONTENTHASH . test ( chunkFilename ) ) {
228
228
hash . update (
229
- JSON . stringify ( chunk . getChunkMaps ( true ) . contentHash [ NS ] || { } )
229
+ JSON . stringify ( chunk . getChunkMaps ( true ) . contentHash [ MODULE_TYPE ] || { } )
230
230
) ;
231
231
}
232
232
if ( REGEXP_NAME . test ( chunkFilename ) ) {
@@ -239,12 +239,12 @@ class MiniCssExtractPlugin {
239
239
const { hashFunction, hashDigest, hashDigestLength } = outputOptions ;
240
240
const hash = createHash ( hashFunction ) ;
241
241
for ( const m of chunk . modulesIterable ) {
242
- if ( m . type === NS ) {
242
+ if ( m . type === MODULE_TYPE ) {
243
243
m . updateHash ( hash ) ;
244
244
}
245
245
}
246
246
const { contentHash } = chunk ;
247
- contentHash [ NS ] = hash
247
+ contentHash [ MODULE_TYPE ] = hash
248
248
. digest ( hashDigest )
249
249
. substring ( 0 , hashDigestLength ) ;
250
250
} ) ;
@@ -294,14 +294,14 @@ class MiniCssExtractPlugin {
294
294
) } [chunkId] + "`;
295
295
} ,
296
296
contentHash : {
297
- [ NS ] : `" + ${ JSON . stringify (
298
- chunkMaps . contentHash [ NS ]
297
+ [ MODULE_TYPE ] : `" + ${ JSON . stringify (
298
+ chunkMaps . contentHash [ MODULE_TYPE ]
299
299
) } [chunkId] + "`,
300
300
} ,
301
301
contentHashWithLength : {
302
- [ NS ] : ( length ) => {
302
+ [ MODULE_TYPE ] : ( length ) => {
303
303
const shortContentHashMap = { } ;
304
- const contentHash = chunkMaps . contentHash [ NS ] ;
304
+ const contentHash = chunkMaps . contentHash [ MODULE_TYPE ] ;
305
305
for ( const chunkId of Object . keys ( contentHash ) ) {
306
306
if ( typeof contentHash [ chunkId ] === 'string' ) {
307
307
shortContentHashMap [ chunkId ] = contentHash [
@@ -318,7 +318,7 @@ class MiniCssExtractPlugin {
318
318
chunkMaps . name
319
319
) } [chunkId]||chunkId) + "`,
320
320
} ,
321
- contentHashType : NS ,
321
+ contentHashType : MODULE_TYPE ,
322
322
}
323
323
) ;
324
324
return Template . asString ( [
@@ -382,7 +382,7 @@ class MiniCssExtractPlugin {
382
382
const obj = { } ;
383
383
for ( const chunk of mainChunk . getAllAsyncChunks ( ) ) {
384
384
for ( const module of chunk . modulesIterable ) {
385
- if ( module . type === NS ) {
385
+ if ( module . type === MODULE_TYPE ) {
386
386
obj [ chunk . id ] = 1 ;
387
387
break ;
388
388
}
0 commit comments