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

feat!: preprocess style tags by default #756

Merged
merged 3 commits into from
Oct 6, 2023
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Sep 23, 2023

fix #733

Follow Vite's behavior to preprocess all CSS by default with postcss or lightningcss.

Note: there's a small optimization in Vite where it skips postcss if there's no @import and postcss plugins. Lightningcss doesn't seem to have that optimization.

This affects preprocessing in component libraries too, but I think they should only have a small impact.

Copy link
Member

@kaisermann kaisermann left a comment

Choose a reason for hiding this comment

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

I guess this is fine too! Repeating what I said in the linked issue: svelte-preprocess will preprocess style blocks without lang if the postcss configuration is found/valid..

@benmccann
Copy link
Member

My main question is whether language-tools would know to run the preprocessor, so I'd want Simon's approval

@dominikg
Copy link
Member

dominikg commented Sep 28, 2023

@dummdidumm objections? My concern is that without a lang= tag, the content of style blocks might not be treated correctly in the ide, eg for the lightningcss case it would choke on nesting or the custom media rule ( #733 ), leading to false positives/squigglies

@benmccann
Copy link
Member

@dummdidumm is on vacation, so you might have to ask again later 😄

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

I'm good with this. The fact that the IDE may give false positives shouldn't hold up this valuable PR - and people can tune their config / add a lang tag if needed. We may also be able to detect some of this inside language tools and don't show CSS errors. And since nested CSS is now part of the spec, the upstream vs code html language service might even support it at some point.

@dominikg dominikg merged commit 7c45024 into main Oct 6, 2023
@dominikg dominikg deleted the preprocess-default branch October 6, 2023 19:59
@github-actions github-actions bot mentioned this pull request Oct 6, 2023
@dominikg
Copy link
Member

dominikg commented Oct 6, 2023

If people report performance regressions from postcss going all over their files without lang=postcss tag, we can add an option to restore the previous behavior or recommend they switch to lightningcss?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vite-plugin-svelte chokes on custom media syntax when using vitePreprocess and Lightning CSS
5 participants