File tree 3 files changed +21
-2
lines changed
packages/vite/src/node/plugins 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -403,7 +403,7 @@ async function fileToBuiltUrl(
403
403
return cached
404
404
}
405
405
406
- const { file, postfix } = splitFileAndPostfix ( id )
406
+ let { file, postfix } = splitFileAndPostfix ( id )
407
407
const content = await fsp . readFile ( file )
408
408
409
409
let url : string
@@ -423,6 +423,11 @@ async function fileToBuiltUrl(
423
423
originalFileName,
424
424
source : content ,
425
425
} )
426
+
427
+ if ( environment . config . command === 'build' && noInlineRE . test ( postfix ) ) {
428
+ postfix = postfix . replace ( noInlineRE , '' ) . replace ( / ^ & / , '?' )
429
+ }
430
+
426
431
url = `__VITE_ASSET__${ referenceId } __${ postfix ? `$_${ postfix } __` : `` } `
427
432
}
428
433
Original file line number Diff line number Diff line change @@ -472,11 +472,19 @@ test('?raw import', async () => {
472
472
test ( '?no-inline svg import' , async ( ) => {
473
473
expect ( await page . textContent ( '.no-inline-svg' ) ) . toMatch (
474
474
isBuild
475
- ? / \/ f o o \/ b a r \/ a s s e t s \/ f r a g m e n t - [ - \w ] { 8 } \. s v g \? n o - i n l i n e /
475
+ ? / \/ f o o \/ b a r \/ a s s e t s \/ f r a g m e n t - [ - \w ] { 8 } \. s v g /
476
476
: '/foo/bar/nested/fragment.svg?no-inline' ,
477
477
)
478
478
} )
479
479
480
+ test ( '?no-inline svg import -- multiple postfix' , async ( ) => {
481
+ expect ( await page . textContent ( '.no-inline-svg-mp' ) ) . toMatch (
482
+ isBuild
483
+ ? / \/ f o o \/ b a r \/ a s s e t s \/ f r a g m e n t - [ - \w ] { 8 } \. s v g \? f o o = b a r /
484
+ : '/foo/bar/nested/fragment.svg?no-inline&foo=bar' ,
485
+ )
486
+ } )
487
+
480
488
test ( '?inline png import' , async ( ) => {
481
489
expect ( await page . textContent ( '.inline-png' ) ) . toMatch (
482
490
/ ^ d a t a : i m a g e \/ p n g ; b a s e 6 4 , / ,
Original file line number Diff line number Diff line change @@ -269,6 +269,9 @@ <h2>?raw import</h2>
269
269
< h2 > ?no-inline svg import</ h2 >
270
270
< code class ="no-inline-svg "> </ code >
271
271
272
+ < h2 > ?no-inline svg import -- multiple postfix</ h2 >
273
+ < code class ="no-inline-svg-mp "> </ code >
274
+
272
275
< h2 > ?inline png import</ h2 >
273
276
< code class ="inline-png "> </ code >
274
277
@@ -546,6 +549,9 @@ <h3>assets in template</h3>
546
549
import noInlineSvg from './nested/fragment.svg?no-inline'
547
550
text ( '.no-inline-svg' , noInlineSvg )
548
551
552
+ import noInlineSvgMP from './nested/fragment.svg?no-inline&foo=bar'
553
+ text ( '.no-inline-svg-mp' , noInlineSvgMP )
554
+
549
555
import inlinePng from './nested/asset.png?inline'
550
556
text ( '.inline-png' , inlinePng )
551
557
You can’t perform that action at this time.
0 commit comments