@@ -84,37 +84,39 @@ module.exports = class SplitChunksPlugin {
84
84
}
85
85
86
86
static normalizeOptions ( options = { } ) {
87
+ const chunkFilenameDelimiter = options . chunkFilenameDelimiter || '~' ;
88
+
87
89
return {
88
90
chunks : options . chunks || "all" ,
89
91
minSize : options . minSize || 0 ,
90
92
minChunks : options . minChunks || 1 ,
91
93
maxAsyncRequests : options . maxAsyncRequests || 1 ,
92
94
maxInitialRequests : options . maxInitialRequests || 1 ,
93
- getName : SplitChunksPlugin . normalizeName ( options . name ) || ( ( ) => { } ) ,
95
+ getName : SplitChunksPlugin . normalizeName ( options . name , chunkFilenameDelimiter ) || ( ( ) => { } ) ,
94
96
filename : options . filename || undefined ,
95
97
getCacheGroups : SplitChunksPlugin . normalizeCacheGroups (
96
- options . cacheGroups
98
+ options . cacheGroups , chunkFilenameDelimiter
97
99
) ,
98
- chunkFilenameDelimiter : options . chunkFilenameDelimiter || '~'
100
+ chunkFilenameDelimiter : chunkFilenameDelimiter
99
101
} ;
100
102
}
101
103
102
- static normalizeName ( option ) {
104
+ static normalizeName ( option , chunkFilenameDelimiter ) {
103
105
if ( option === true ) {
104
106
const fn = ( module , chunks , cacheGroup ) => {
105
107
const names = chunks . map ( c => c . name ) ;
106
108
if ( ! names . every ( Boolean ) ) return ;
107
109
names . sort ( ) ;
108
110
let name =
109
- ( cacheGroup && cacheGroup !== "default" ? cacheGroup + this . options . chunkFilenameDelimiter : "" ) +
110
- names . join ( this . options . chunkFilenameDelimiter ) ;
111
+ ( cacheGroup && cacheGroup !== "default" ? cacheGroup + chunkFilenameDelimiter : "" ) +
112
+ names . join ( chunkFilenameDelimiter ) ;
111
113
// Filenames and paths can't be too long otherwise an
112
114
// ENAMETOOLONG error is raised. If the generated name if too
113
115
// long, it is truncated and a hash is appended. The limit has
114
116
// been set to 100 to prevent `[name].[chunkhash].[ext]` from
115
117
// generating a 256+ character string.
116
118
if ( name . length > 100 ) {
117
- name = name . slice ( 0 , 100 ) + this . options . chunkFilenameDelimiter + hashFilename ( name ) ;
119
+ name = name . slice ( 0 , 100 ) + chunkFilenameDelimiter + hashFilename ( name ) ;
118
120
}
119
121
return name ;
120
122
} ;
@@ -129,7 +131,7 @@ module.exports = class SplitChunksPlugin {
129
131
if ( typeof option === "function" ) return option ;
130
132
}
131
133
132
- static normalizeCacheGroups ( cacheGroups ) {
134
+ static normalizeCacheGroups ( cacheGroups , chunkFilenameDelimiter ) {
133
135
if ( typeof cacheGroups === "function" ) {
134
136
return cacheGroups ;
135
137
}
@@ -164,7 +166,7 @@ module.exports = class SplitChunksPlugin {
164
166
results . push ( {
165
167
key : key ,
166
168
priority : option . priority ,
167
- getName : SplitChunksPlugin . normalizeName ( option . name ) ,
169
+ getName : SplitChunksPlugin . normalizeName ( option . name , chunkFilenameDelimiter ) ,
168
170
chunks : option . chunks ,
169
171
enforce : option . enforce ,
170
172
minSize : option . minSize ,
0 commit comments