Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b0a0355

Browse files
kevinchappellevilebottnawi
authored andcommittedApr 23, 2019
perf: match filename placeholders with regular expression (#383)
1 parent 44d00ea commit b0a0355

File tree

2 files changed

+49
-60
lines changed

2 files changed

+49
-60
lines changed
 

‎package-lock.json

Lines changed: 47 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ 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;
1920

2021
class CssDependency extends webpack.Dependency {
2122
constructor(
@@ -128,12 +129,9 @@ class MiniCssExtractPlugin {
128129

129130
if (!this.options.chunkFilename) {
130131
const { filename } = this.options;
131-
const hasName = filename.includes('[name]');
132-
const hasId = filename.includes('[id]');
133-
const hasChunkHash = filename.includes('[chunkhash]');
134132

135133
// Anything changing depending on chunk is fine
136-
if (hasChunkHash || hasName || hasId) {
134+
if (filename.match(REGEXP_PLACEHOLDERS)) {
137135
this.options.chunkFilename = filename;
138136
} else {
139137
// Elsewise prefix '[id].' in front of the basename to make it changing

0 commit comments

Comments
 (0)
Please sign in to comment.