Skip to content

fix(css): resolve relative imports in sass properly on Windows#19920

Merged
sapphi-red merged 1 commit intovitejs:mainfrom
sapphi-red:fix/css-sass-relative-windows-properly
Apr 24, 2025
Merged

fix(css): resolve relative imports in sass properly on Windows#19920
sapphi-red merged 1 commit intovitejs:mainfrom
sapphi-red:fix/css-sass-relative-windows-properly

Conversation

@sapphi-red
Copy link
Copy Markdown
Member

Description

fileURLToPath('file:///C:/foo.js', { windows: false }) returns /C:/foo.js. Even with this output, it still worked because the internal resolve plugin supports that format (/C:/foo.js) as well.

// URL
// /foo -> /fs-root/foo
if (
asSrc &&
id[0] === '/' &&
(rootInRoot || !id.startsWith(withTrailingSlash(root)))
) {
const fsPath = path.resolve(root, id.slice(1))
if ((res = tryFsResolve(fsPath, options))) {
debug?.(`[url] ${colors.cyan(id)} -> ${colors.dim(res)}`)
return ensureVersionQuery(res, id, options, depsOptimizer)
}
}

But the expected result here for this input is C:/foo.js, and this PR fixes the condition to use windows option.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: css p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants