Skip to content

Commit b803c64

Browse files
committed
Added chunkFilenameDelimiter option for SplitChunksPlugin: Fixed parameter
1 parent 36db321 commit b803c64

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/optimize/SplitChunksPlugin.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,37 +84,39 @@ module.exports = class SplitChunksPlugin {
8484
}
8585

8686
static normalizeOptions(options = {}) {
87+
const chunkFilenameDelimiter = options.chunkFilenameDelimiter || '~';
88+
8789
return {
8890
chunks: options.chunks || "all",
8991
minSize: options.minSize || 0,
9092
minChunks: options.minChunks || 1,
9193
maxAsyncRequests: options.maxAsyncRequests || 1,
9294
maxInitialRequests: options.maxInitialRequests || 1,
93-
getName: SplitChunksPlugin.normalizeName(options.name) || (() => {}),
95+
getName: SplitChunksPlugin.normalizeName(options.name, chunkFilenameDelimiter) || (() => {}),
9496
filename: options.filename || undefined,
9597
getCacheGroups: SplitChunksPlugin.normalizeCacheGroups(
96-
options.cacheGroups
98+
options.cacheGroups, chunkFilenameDelimiter
9799
),
98-
chunkFilenameDelimiter: options.chunkFilenameDelimiter || '~'
100+
chunkFilenameDelimiter: chunkFilenameDelimiter
99101
};
100102
}
101103

102-
static normalizeName(option) {
104+
static normalizeName(option, chunkFilenameDelimiter) {
103105
if (option === true) {
104106
const fn = (module, chunks, cacheGroup) => {
105107
const names = chunks.map(c => c.name);
106108
if (!names.every(Boolean)) return;
107109
names.sort();
108110
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);
111113
// Filenames and paths can't be too long otherwise an
112114
// ENAMETOOLONG error is raised. If the generated name if too
113115
// long, it is truncated and a hash is appended. The limit has
114116
// been set to 100 to prevent `[name].[chunkhash].[ext]` from
115117
// generating a 256+ character string.
116118
if (name.length > 100) {
117-
name = name.slice(0, 100) + this.options.chunkFilenameDelimiter + hashFilename(name);
119+
name = name.slice(0, 100) + chunkFilenameDelimiter + hashFilename(name);
118120
}
119121
return name;
120122
};
@@ -129,7 +131,7 @@ module.exports = class SplitChunksPlugin {
129131
if (typeof option === "function") return option;
130132
}
131133

132-
static normalizeCacheGroups(cacheGroups) {
134+
static normalizeCacheGroups(cacheGroups, chunkFilenameDelimiter) {
133135
if (typeof cacheGroups === "function") {
134136
return cacheGroups;
135137
}
@@ -164,7 +166,7 @@ module.exports = class SplitChunksPlugin {
164166
results.push({
165167
key: key,
166168
priority: option.priority,
167-
getName: SplitChunksPlugin.normalizeName(option.name),
169+
getName: SplitChunksPlugin.normalizeName(option.name, chunkFilenameDelimiter),
168170
chunks: option.chunks,
169171
enforce: option.enforce,
170172
minSize: option.minSize,

0 commit comments

Comments
 (0)