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 @@ -1101,10 +1101,17 @@ UrlRewritePostcssPlugin.postcss = true
1101
1101
1102
1102
function rewriteCssUrls (
1103
1103
css : string ,
1104
- replacer : CssUrlReplacer
1104
+ replacer : CssUrlReplacer ,
1105
+ file ?: string
1105
1106
) : Promise < string > {
1106
1107
return asyncReplace ( css , cssUrlRE , async ( match ) => {
1107
1108
const [ matched , rawUrl ] = match
1109
+ const inLess = file ?. endsWith ( '.less' )
1110
+ const inSass = file ?. endsWith ( '.sass' )
1111
+ const inScss = file ?. endsWith ( '.scss' )
1112
+ if ( inLess && rawUrl . startsWith ( '@' ) || ( inSass || inScss ) && rawUrl . startsWith ( '$' ) ) {
1113
+ return `url('${ rawUrl } ')`
1114
+ }
1108
1115
return await doUrlReplace ( rawUrl , matched , replacer )
1109
1116
} )
1110
1117
}
@@ -1478,7 +1485,7 @@ async function rebaseUrls(
1478
1485
}
1479
1486
1480
1487
if ( hasUrls ) {
1481
- rebased = await rewriteCssUrls ( rebased || content , rebaseFn )
1488
+ rebased = await rewriteCssUrls ( rebased || content , rebaseFn , file )
1482
1489
}
1483
1490
1484
1491
if ( hasDataUris ) {
You can’t perform that action at this time.
0 commit comments