Skip to content

Commit b125172

Browse files
authored
fix(css): remove empty chunk imports correctly when chunk file name contained special characters (#19814)
1 parent 93d639e commit b125172

File tree

1 file changed

+2
-2
lines changed
  • packages/vite/src/node/plugins

1 file changed

+2
-2
lines changed

packages/vite/src/node/plugins/css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {
6565
createSerialPromiseQueue,
6666
emptyCssComments,
6767
encodeURIPath,
68+
escapeRegex,
6869
generateCodeFrame,
6970
getHash,
7071
getPackageManagerCommand,
@@ -1161,9 +1162,8 @@ export function getEmptyChunkReplacer(
11611162
outputFormat: ModuleFormat,
11621163
): (code: string) => string {
11631164
const emptyChunkFiles = pureCssChunkNames
1164-
.map((file) => path.basename(file))
1165+
.map((file) => escapeRegex(path.basename(file)))
11651166
.join('|')
1166-
.replace(/\./g, '\\.')
11671167

11681168
// for cjs, require calls might be chained by minifier using the comma operator.
11691169
// in this case we have to keep one comma if a next require is chained

0 commit comments

Comments
 (0)