File tree 3 files changed +18
-7
lines changed
packages/vite/src/node/plugins
3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -463,13 +463,15 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
463
463
}
464
464
}
465
465
}
466
- // <tag style="... url(...) ..."></tag>
466
+ // <tag style="... url(...) or image-set(...) ..."></tag>
467
467
// extract inline styles as virtual css and add class attribute to tag for selecting
468
468
const inlineStyle = node . attrs . find (
469
469
( prop ) =>
470
470
prop . prefix === undefined &&
471
471
prop . name === 'style' &&
472
- prop . value . includes ( 'url(' ) , // only url(...) in css need to emit file
472
+ // only url(...) or image-set(...) in css need to emit file
473
+ ( prop . value . includes ( 'url(' ) ||
474
+ prop . value . includes ( 'image-set(' ) ) ,
473
475
)
474
476
if ( inlineStyle ) {
475
477
inlineModuleIndex ++
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ describe('css url() references', () => {
148
148
expect ( imageSet ) . toContain ( 'image-set(url("data:image/png;base64,' )
149
149
} )
150
150
151
- test ( 'image-set with multiple descriptor ' , async ( ) => {
151
+ test ( 'image-set with gradient ' , async ( ) => {
152
152
const imageSet = await getBg ( '.css-image-set-gradient' )
153
153
expect ( imageSet ) . toContain ( 'image-set(url("data:image/png;base64,' )
154
154
} )
@@ -160,6 +160,15 @@ describe('css url() references', () => {
160
160
} )
161
161
} )
162
162
163
+ test ( 'image-set with multiple descriptor as inline style' , async ( ) => {
164
+ const imageSet = await getBg (
165
+ '.css-image-set-multiple-descriptor-inline-style' ,
166
+ )
167
+ imageSet . split ( ', ' ) . forEach ( ( s ) => {
168
+ expect ( s ) . toMatch ( assetMatch )
169
+ } )
170
+ } )
171
+
163
172
test ( 'relative in @import' , async ( ) => {
164
173
expect ( await getBg ( '.css-url-relative-at-imported' ) ) . toMatch ( assetMatch )
165
174
} )
Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ <h2>CSS url references</h2>
71
71
CSS background image-set() (with multiple descriptor)
72
72
</ span >
73
73
</ div >
74
- <!-- image-set in style tags is not supported in Vite yet -->
75
- <!-- <div
74
+ < div
75
+ class =" css-image-set-multiple-descriptor-inline-style "
76
76
style ="
77
77
background-image: -webkit-image-set(
78
78
'./nested/asset.png' type('image/png') 1x,
@@ -82,9 +82,9 @@ <h2>CSS url references</h2>
82
82
"
83
83
>
84
84
< span style ="background: #fff ">
85
- CSS background image-set() (with multiple descriptor)
85
+ CSS background image-set() inline style (with multiple descriptor)
86
86
</ span >
87
- </div> -->
87
+ </ div >
88
88
< div class ="css-url-relative-at-imported ">
89
89
< span style ="background: #fff "
90
90
> CSS background (relative from @imported file in different dir)</ span
You can’t perform that action at this time.
0 commit comments