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

Extract rules with resolved variables to another stylesheet #59

Open
tawgul opened this issue Aug 23, 2017 · 6 comments
Open

Extract rules with resolved variables to another stylesheet #59

tawgul opened this issue Aug 23, 2017 · 6 comments

Comments

@tawgul
Copy link

tawgul commented Aug 23, 2017

Hi.

CSS Variable are quite well supported but are not in IE11<=11 and Android < 5.

So I was thinking if we could take the calculated rules and move to external file?

And load this file with JS (after detecting support for CSS variables)?

@MadLittleMods
Copy link
Owner

This plugin only compiles statically and isn't an active polyfill/shim to be loaded in the browser.

If you wanted to use this plugin you could conditionally load in a stylesheet that ran through this plugin.

Otherwise you will probably be better off looking for a "CSS custom properties polyfill".

@tawgul
Copy link
Author

tawgul commented Aug 23, 2017

You get me wrong.
I use it already with Gulp and it works fine and I like the preserve:true option to have the computed values for IE11 and original ones for other browsers.

And I was thinking of that when you get all the variables and create the computed values to extract them to external file (so you grab them into array and at the end we create a new file with declarations with computed values).

This way I could leave original variables for modern browsers (so original file is intact) and a new file with computed declarations could be served for browsers not supporting CSS Variables.

@MadLittleMods
Copy link
Owner

@TAWG It's probably possible, create a new root to attach the resolved rules to, see

// Resolve variables everywhere

I'd have to dive deeper on how best to support saving out multiple files (any other plugins that do that save out multiple files?). Feel free to create a PR if you are thinking of something slick 😀

@MadLittleMods MadLittleMods reopened this Aug 23, 2017
@MadLittleMods MadLittleMods changed the title Calculated values in external file? Extract rules with resolved variables to another stylesheet Aug 23, 2017
@tawgul
Copy link
Author

tawgul commented Aug 30, 2017

OK.

@Mangatt
Copy link

Mangatt commented Jan 7, 2020

We want to go this way as well for our websites. I think it's much more better approach to conditionally load old IE CSS than pollute all CSS with fallbacks.

This plugin is not able to keep just transformed rules instead of complete file?

@MadLittleMods
Copy link
Owner

@Mangatt Not currently possible. But is feasible where I linked some code above. I don't have something specific in mind to solve this.

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

No branches or pull requests

3 participants