Skip to content

Commit ffab442

Browse files
authored
fix(css): resolve relative imports in sass properly on Windows (#19920)
1 parent 16a73c0 commit ffab442

File tree

1 file changed

+5
-1
lines changed
  • packages/vite/src/node/plugins

1 file changed

+5
-1
lines changed

packages/vite/src/node/plugins/css.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,8 @@ export function getEmptyChunkReplacer(
12071207
)
12081208
}
12091209

1210+
const fileURLWithWindowsDriveRE = /^file:\/\/\/[a-zA-Z]:\//
1211+
12101212
interface CSSAtImportResolvers {
12111213
css: ResolveIdFn
12121214
sass: ResolveIdFn
@@ -1245,7 +1247,9 @@ function createCSSResolvers(config: ResolvedConfig): CSSAtImportResolvers {
12451247
args[1] = fileURLToPath(args[1], {
12461248
windows:
12471249
// file:///foo cannot be converted to path with windows mode
1248-
isWindows && args[1].startsWith('file:///') ? false : undefined,
1250+
isWindows && !fileURLWithWindowsDriveRE.test(args[1])
1251+
? false
1252+
: undefined,
12491253
})
12501254
}
12511255
return resolver(...args)

0 commit comments

Comments
 (0)