Skip to content

Commit 36db321

Browse files
committed
Added chunkFilenameDelimiter option for SplitChunksPlugin
1 parent 41bb63a commit 36db321

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

lib/WebpackOptionsDefaulter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
210210
this.set("optimization.splitChunks.minSize", 30000);
211211
this.set("optimization.splitChunks.minChunks", 1);
212212
this.set("optimization.splitChunks.maxAsyncRequests", 5);
213+
this.set("optimization.splitChunks.chunkFilenameDelimiter", "~");
213214
this.set("optimization.splitChunks.maxInitialRequests", 3);
214215
this.set("optimization.splitChunks.name", true);
215216
this.set("optimization.splitChunks.cacheGroups", {});

lib/WebpackOptionsValidationError.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class WebpackOptionsValidationError extends WebpackError {
6565

6666
this.name = "WebpackOptionsValidationError";
6767
this.message =
68-
"Invalid configuration object. " +
68+
"Invalid configuration object. :( " +
6969
"Webpack has been initialised using a configuration object that does not match the API schema.\n" +
7070
validationErrors
7171
.map(

lib/optimize/SplitChunksPlugin.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ module.exports = class SplitChunksPlugin {
9494
filename: options.filename || undefined,
9595
getCacheGroups: SplitChunksPlugin.normalizeCacheGroups(
9696
options.cacheGroups
97-
)
97+
),
98+
chunkFilenameDelimiter: options.chunkFilenameDelimiter || '~'
9899
};
99100
}
100101

@@ -105,15 +106,15 @@ module.exports = class SplitChunksPlugin {
105106
if (!names.every(Boolean)) return;
106107
names.sort();
107108
let name =
108-
(cacheGroup && cacheGroup !== "default" ? cacheGroup + "~" : "") +
109-
names.join("~");
109+
(cacheGroup && cacheGroup !== "default" ? cacheGroup + this.options.chunkFilenameDelimiter : "") +
110+
names.join(this.options.chunkFilenameDelimiter);
110111
// Filenames and paths can't be too long otherwise an
111112
// ENAMETOOLONG error is raised. If the generated name if too
112113
// long, it is truncated and a hash is appended. The limit has
113114
// been set to 100 to prevent `[name].[chunkhash].[ext]` from
114115
// generating a 256+ character string.
115116
if (name.length > 100) {
116-
name = name.slice(0, 100) + "~" + hashFilename(name);
117+
name = name.slice(0, 100) + this.options.chunkFilenameDelimiter + hashFilename(name);
117118
}
118119
return name;
119120
};

schemas/WebpackOptions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,11 @@
13821382
"type": "string",
13831383
"minLength": 1
13841384
},
1385+
"chunkFilenameDelimiter": {
1386+
"description": "Sets the filename delimiter for created chunks",
1387+
"type": "string",
1388+
"minLength": 1
1389+
},
13851390
"cacheGroups": {
13861391
"description": "Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks)",
13871392
"type": "object",

0 commit comments

Comments
 (0)