Skip to content

fix(css): remove alias exclude logic from rebaseUrl#20100

Merged
patak-cat merged 1 commit intovitejs:mainfrom
sapphi-red:refactor/css-remove-alias-exclude-logic-from-rebaseurl
May 26, 2025
Merged

fix(css): remove alias exclude logic from rebaseUrl#20100
patak-cat merged 1 commit intovitejs:mainfrom
sapphi-red:refactor/css-remove-alias-exclude-logic-from-rebaseurl

Conversation

@sapphi-red
Copy link
Copy Markdown
Member

Description

This part of code was added by #2323.

// match alias, no need to rewrite
for (const { find } of alias) {
const matches =
typeof find === 'string'
? unquotedUrl.startsWith(find)
: find.test(unquotedUrl)
if (matches) {
return unquotedUrl
}
}

This excludes url(value)s that uses aliases from being rebased. Then that was rebased by UrlRewritePostcssPlugin.
UrlRewritePostcssPlugin({
resolver: urlResolver,
deps,
logger: environment.logger,
}),

While this works fine in most cases, this is incorrect when the replacement is a relative path (e.g. alias: { '@foo': '../foo' }).

That said, this PR would make the implementation more simple and that was the initial motivation.

@sapphi-red sapphi-red added feat: css p1-chore Doesn't change code behavior (priority) labels May 24, 2025
@patak-cat patak-cat merged commit 44c6d01 into vitejs:main May 26, 2025
17 checks passed
@sapphi-red sapphi-red deleted the refactor/css-remove-alias-exclude-logic-from-rebaseurl branch May 27, 2025 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: css p1-chore Doesn't change code behavior (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants