File tree 1 file changed +6
-2
lines changed
packages/plugin-legacy/src
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,9 @@ const legacyEnvVarMarker = `__VITE_IS_LEGACY__`
119
119
120
120
const _require = createRequire ( import . meta. url )
121
121
122
+ const nonLeadingHashInFileNameRE = / [ ^ / ] + \[ h a s h (?: : \d + ) ? \] /
123
+ const prefixedHashInFileNameRE = / [ . - ] ? \[ h a s h ( : \d + ) ? \] /
124
+
122
125
function viteLegacyPlugin ( options : Options = { } ) : Plugin [ ] {
123
126
let config : ResolvedConfig
124
127
let targets : Options [ 'targets' ]
@@ -337,11 +340,12 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
337
340
if ( fileName . includes ( '[name]' ) ) {
338
341
// [name]-[hash].[format] -> [name]-legacy-[hash].[format]
339
342
fileName = fileName . replace ( '[name]' , '[name]-legacy' )
340
- } else if ( fileName . includes ( '[hash]' ) ) {
343
+ } else if ( nonLeadingHashInFileNameRE . test ( fileName ) ) {
341
344
// custom[hash].[format] -> [name]-legacy[hash].[format]
342
345
// custom-[hash].[format] -> [name]-legacy-[hash].[format]
343
346
// custom.[hash].[format] -> [name]-legacy.[hash].[format]
344
- fileName = fileName . replace ( / [ . - ] ? \[ h a s h \] / , '-legacy$&' )
347
+ // custom.[hash:10].[format] -> custom-legacy.[hash:10].[format]
348
+ fileName = fileName . replace ( prefixedHashInFileNameRE , '-legacy$&' )
345
349
} else {
346
350
// entry.js -> entry-legacy.js
347
351
// entry.min.js -> entry-legacy.min.js
You can’t perform that action at this time.
0 commit comments