Skip to content

Commit

Permalink
feat: remove console.log's
Browse files Browse the repository at this point in the history
Store filename in options, this way function is called once
  • Loading branch information
berthertogen committed May 25, 2018
1 parent 835624c commit 44cd88f
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ class MiniCssExtractPlugin {
renderedModules,
compilation.runtimeTemplate.requestShortener
),
filenameTemplate: this.getFilename(chunk, this.options.filename),
filenameTemplate: this.getFilename(
chunk,
this.options.filename,
this.options.processedFilename
),
pathOptions: {
chunk,
contentHashType: NS,
Expand All @@ -196,7 +200,8 @@ class MiniCssExtractPlugin {
),
filenameTemplate: this.getFilename(
chunk,
this.options.chunkFilename
this.options.chunkFilename,
this.options.processedChunkFilename
),
pathOptions: {
chunk,
Expand Down Expand Up @@ -264,7 +269,11 @@ class MiniCssExtractPlugin {
const chunkMaps = chunk.getChunkMaps();
const linkHrefPath = mainTemplate.getAssetPath(
JSON.stringify(
this.getFilename(chunk, this.options.chunkFilename)
this.getFilename(
chunk,
this.options.chunkFilename,
this.options.processedChunkFilename
)
),
{
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
Expand Down Expand Up @@ -371,10 +380,13 @@ class MiniCssExtractPlugin {
});
}

getFilename(chunk, filename) {
console.log('--chunk--');
console.log(chunk);
return this.isFunction(filename) ? filename(chunk) : filename;
getFilename(chunk, filename, processedFilename) {
if (!processedFilename) {
processedFilename = this.isFunction(filename)
? filename(chunk)
: filename;
}
return processedFilename;
}

isFunction(functionToCheck) {
Expand Down

0 comments on commit 44cd88f

Please sign in to comment.