-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Support global styles - Allow multiple top-level style tag declarations with different attributes #2762
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
Comments
What do you think Svelte should do in this case? Just treat all of the style rules in all of the style tags equally? Adding this in a naive way would be a breaking change for tooling that relies on the current AST structure, because that currently only provides a way for there to be one style tag. I don't know whether this is enough of a reason to not do it. |
It seems like this would entail supporting an array of style blocks, instead of single block. The style blocks can then be processed with their respective processors (via the type attribute) & then combined into a single stylesheet for the component, which would each be combined during the build process. Most components would only have a single In the AST, is the In the case of unprocessed Is there a formal grammar of a svelte component somewhere? |
I think it absolutely is worth potentially breaking things to make this change. Personally, in general, I don't use scoped styles, but like to keep open the option of using them as they are sometimes useful. |
@Conduitry supporting free styles is very important, for example how to use |
It has been determined that there is a fundamental need for the functionality this provides, but this isn't the right approach. This approach is however currently available with preprocessors. Moving discussion to sveltejs/rfcs#13 |
There are a couple of plugins that support globally scoped style tags.
https://www.npmjs.com/package/svelte-preprocess-css-global
https://www.npmjs.com/package/@ctx-core/sass
This naturally leads to the pattern to have both a global & a non-global style block for a component.
Unfortunately, Svelte gives an error
You can only have one top-level <style> tag per component
. Since there is some usage of global style tags, along with a rfc, it's time to modify this requirement if there are<style>
tags with different attributes.The text was updated successfully, but these errors were encountered: