Skip to content

Commit 9465a4c

Browse files
committed
fix(filename): fix usage of filenameTemplate
using filenameTemplate is incorrect It would point to a .js filename.
1 parent 0a3362d commit 9465a4c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class MiniCssExtractPlugin {
5959
}
6060
}
6161

62+
/** @param {import("webpack").Compiler} compiler */
6263
apply(compiler) {
6364
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
6465
compilation.dependencyFactories.set(
@@ -149,13 +150,9 @@ class MiniCssExtractPlugin {
149150
this.getChunkModules(chunk, chunkGraph)
150151
).filter((module) => module.type === MODULE_TYPE);
151152

152-
const filenameTemplate =
153-
chunk.filenameTemplate ||
154-
chunk.hasRuntime() ||
155-
chunk.isOnlyInitial()
156-
? ({ chunk: chunkData }) =>
157-
this.options.moduleFilename(chunkData)
158-
: this.options.chunkFilename;
153+
const filenameTemplate = chunk.canBeInitial()
154+
? ({ chunk: chunkData }) => this.options.moduleFilename(chunkData)
155+
: this.options.chunkFilename;
159156

160157
if (renderedModules.length > 0) {
161158
result.push({

0 commit comments

Comments
 (0)