Skip to content

Commit ef33e7d

Browse files
committed
refactor: move placeholder regexp to another PR
1 parent 62ecfe9 commit ef33e7d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: src/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const pluginName = 'mini-css-extract-plugin';
1616
const REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/i;
1717
const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/i;
1818
const REGEXP_NAME = /\[name\]/i;
19-
const REGEXP_PLACEHOLDERS = /\[(name|id|chunkhash)\]/g;
2019
const DEFAULT_FILENAME = '[name].css';
2120

2221
class CssDependency extends webpack.Dependency {
@@ -131,9 +130,12 @@ class MiniCssExtractPlugin {
131130

132131
if (!this.options.chunkFilename) {
133132
const { filename } = this.options;
133+
const hasName = filename.includes('[name]');
134+
const hasId = filename.includes('[id]');
135+
const hasChunkHash = filename.includes('[chunkhash]');
134136

135137
// Anything changing depending on chunk is fine
136-
if (REGEXP_PLACEHOLDERS.test(filename)) {
138+
if (hasChunkHash || hasName || hasId) {
137139
this.options.chunkFilename = filename;
138140
} else {
139141
// Elsewise prefix '[id].' in front of the basename to make it changing

0 commit comments

Comments
 (0)