Skip to content

Commit 44cd88f

Browse files
committed
feat: remove console.log's
Store filename in options, this way function is called once
1 parent 835624c commit 44cd88f

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/index.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ class MiniCssExtractPlugin {
170170
renderedModules,
171171
compilation.runtimeTemplate.requestShortener
172172
),
173-
filenameTemplate: this.getFilename(chunk, this.options.filename),
173+
filenameTemplate: this.getFilename(
174+
chunk,
175+
this.options.filename,
176+
this.options.processedFilename
177+
),
174178
pathOptions: {
175179
chunk,
176180
contentHashType: NS,
@@ -196,7 +200,8 @@ class MiniCssExtractPlugin {
196200
),
197201
filenameTemplate: this.getFilename(
198202
chunk,
199-
this.options.chunkFilename
203+
this.options.chunkFilename,
204+
this.options.processedChunkFilename
200205
),
201206
pathOptions: {
202207
chunk,
@@ -264,7 +269,11 @@ class MiniCssExtractPlugin {
264269
const chunkMaps = chunk.getChunkMaps();
265270
const linkHrefPath = mainTemplate.getAssetPath(
266271
JSON.stringify(
267-
this.getFilename(chunk, this.options.chunkFilename)
272+
this.getFilename(
273+
chunk,
274+
this.options.chunkFilename,
275+
this.options.processedChunkFilename
276+
)
268277
),
269278
{
270279
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
@@ -371,10 +380,13 @@ class MiniCssExtractPlugin {
371380
});
372381
}
373382

374-
getFilename(chunk, filename) {
375-
console.log('--chunk--');
376-
console.log(chunk);
377-
return this.isFunction(filename) ? filename(chunk) : filename;
383+
getFilename(chunk, filename, processedFilename) {
384+
if (!processedFilename) {
385+
processedFilename = this.isFunction(filename)
386+
? filename(chunk)
387+
: filename;
388+
}
389+
return processedFilename;
378390
}
379391

380392
isFunction(functionToCheck) {

0 commit comments

Comments
 (0)