File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -403,7 +403,7 @@ async function fileToBuiltUrl(
403403 return cached
404404 }
405405
406- const { file, postfix } = splitFileAndPostfix ( id )
406+ let { file, postfix } = splitFileAndPostfix ( id )
407407 const content = await fsp . readFile ( file )
408408
409409 let url : string
@@ -423,6 +423,11 @@ async function fileToBuiltUrl(
423423 originalFileName,
424424 source : content ,
425425 } )
426+
427+ if ( environment . config . command === 'build' && noInlineRE . test ( postfix ) ) {
428+ postfix = postfix . replace ( noInlineRE , '' ) . replace ( / ^ & / , '?' )
429+ }
430+
426431 url = `__VITE_ASSET__${ referenceId } __${ postfix ? `$_${ postfix } __` : `` } `
427432 }
428433
Original file line number Diff line number Diff line change @@ -472,11 +472,19 @@ test('?raw import', async () => {
472472test ( '?no-inline svg import' , async ( ) => {
473473 expect ( await page . textContent ( '.no-inline-svg' ) ) . toMatch (
474474 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 /
476476 : '/foo/bar/nested/fragment.svg?no-inline' ,
477477 )
478478} )
479479
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+
480488test ( '?inline png import' , async ( ) => {
481489 expect ( await page . textContent ( '.inline-png' ) ) . toMatch (
482490 / ^ 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>
269269< h2 > ?no-inline svg import</ h2 >
270270< code class ="no-inline-svg "> </ code >
271271
272+ < h2 > ?no-inline svg import -- multiple postfix</ h2 >
273+ < code class ="no-inline-svg-mp "> </ code >
274+
272275< h2 > ?inline png import</ h2 >
273276< code class ="inline-png "> </ code >
274277
@@ -546,6 +549,9 @@ <h3>assets in template</h3>
546549 import noInlineSvg from './nested/fragment.svg?no-inline'
547550 text ( '.no-inline-svg' , noInlineSvg )
548551
552+ import noInlineSvgMP from './nested/fragment.svg?no-inline&foo=bar'
553+ text ( '.no-inline-svg-mp' , noInlineSvgMP )
554+
549555 import inlinePng from './nested/asset.png?inline'
550556 text ( '.inline-png' , inlinePng )
551557
You can’t perform that action at this time.
0 commit comments