Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(css): handle url replacing when preprocessing with lightningcss #17364

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented May 31, 2024

Description

When using preprocessCSS with lightningcss, urlReplacer is undefined, so the css urls should be left intact but we didn't replace the placeholder back to original in this case.

(from astro) closes withastro/astro#11060 (comment)

@bluwy bluwy added feat: css p3-minor-bug An edge case that only affects very specific usage (priority) labels May 31, 2024
Copy link

stackblitz bot commented May 31, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@@ -2780,6 +2780,8 @@ async function compileLightningCSS(
if (urlReplacer) {
const replaceUrl = await urlReplacer(dep.url, id)
css = css.replace(dep.placeholder, () => replaceUrl)
} else {
css = css.replace(dep.placeholder, () => dep.url)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the replace function use a function as the second parameter? This seems unnecessary. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because of #16306

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the link.
This seems a bit weird, it's the first time I've come across this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patak-dev patak-dev merged commit 6fbb5e0 into main Jun 3, 2024
11 checks passed
@patak-dev patak-dev deleted the css-lightning-preprocess branch June 3, 2024 06:27
@bluwy bluwy mentioned this pull request Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lightningcss does not resolve url() inside an astro scoped style
3 participants