Skip to content

Commit

Permalink
Merge pull request #6672 from EugeneHlushko/fix/6639
Browse files Browse the repository at this point in the history
fix(bug): chunkFilename as function doesn't work
  • Loading branch information
sokra committed Mar 29, 2018
2 parents f600ccd + aa55324 commit b30de38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
18 changes: 10 additions & 8 deletions lib/WebpackOptionsDefaulter.js
Expand Up @@ -91,14 +91,16 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("output.filename", "[name].js");
this.set("output.chunkFilename", "make", options => {
const filename = options.output.filename;
if (typeof filename === "function") return filename;
const hasName = filename.includes("[name]");
const hasId = filename.includes("[id]");
const hasChunkHash = filename.includes("[chunkhash]");
// Anything changing depending on chunk is fine
if (hasChunkHash || hasName || hasId) return filename;
// Elsewise prefix "[id]." in front of the basename to make it changing
return filename.replace(/(^|\/)([^/]*(?:\?|$))/, "$1[id].$2");
if (typeof filename !== "function") {
const hasName = filename.includes("[name]");
const hasId = filename.includes("[id]");
const hasChunkHash = filename.includes("[chunkhash]");
// Anything changing depending on chunk is fine
if (hasChunkHash || hasName || hasId) return filename;
// Elsewise prefix "[id]." in front of the basename to make it changing
return filename.replace(/(^|\/)([^/]*(?:\?|$))/, "$1[id].$2");
}
return "[id].js";
});
this.set("output.webassemblyModuleFilename", "[modulehash].module.wasm");
this.set("output.library", "");
Expand Down
9 changes: 1 addition & 8 deletions schemas/WebpackOptions.json
Expand Up @@ -324,14 +324,7 @@
},
"chunkFilename": {
"description": "The filename of non-entry chunks as relative path inside the `output.path` directory.",
"anyOf": [
{
"type": "string"
},
{
"instanceof": "Function"
}
],
"type": "string",
"absolutePath": false
},
"webassemblyModuleFilename": {
Expand Down

0 comments on commit b30de38

Please sign in to comment.