File tree 1 file changed +9
-2
lines changed
packages/vite/src/node/plugins
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1209,10 +1209,17 @@ UrlRewritePostcssPlugin.postcss = true
1209
1209
1210
1210
function rewriteCssUrls (
1211
1211
css : string ,
1212
- replacer : CssUrlReplacer
1212
+ replacer : CssUrlReplacer ,
1213
+ file ?: string
1213
1214
) : Promise < string > {
1214
1215
return asyncReplace ( css , cssUrlRE , async ( match ) => {
1215
1216
const [ matched , rawUrl ] = match
1217
+ const inLess = file ?. endsWith ( '.less' )
1218
+ const inSass = file ?. endsWith ( '.sass' )
1219
+ const inScss = file ?. endsWith ( '.scss' )
1220
+ if ( inLess && rawUrl . startsWith ( '@' ) || ( inSass || inScss ) && rawUrl . startsWith ( '$' ) ) {
1221
+ return `url('${ rawUrl } ')`
1222
+ }
1216
1223
return await doUrlReplace ( rawUrl , matched , replacer )
1217
1224
} )
1218
1225
}
@@ -1621,7 +1628,7 @@ async function rebaseUrls(
1621
1628
}
1622
1629
1623
1630
if ( hasUrls ) {
1624
- rebased = await rewriteCssUrls ( rebased || content , rebaseFn )
1631
+ rebased = await rewriteCssUrls ( rebased || content , rebaseFn , file )
1625
1632
}
1626
1633
1627
1634
if ( hasDataUris ) {
You can’t perform that action at this time.
0 commit comments