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

CSS variables cause build failure #757

Closed
colah opened this issue Aug 7, 2017 · 3 comments · Fixed by #796
Closed

CSS variables cause build failure #757

colah opened this issue Aug 7, 2017 · 3 comments · Fixed by #796
Labels

Comments

@colah
Copy link

colah commented Aug 7, 2017

Setting a CSS variable in a <style> section of a svelte template triggers a build error:

<style>
.foo {  --test: 10; }
</style>
Module build failed: Error: TypeError: Cannot read property '0' of undefined

I don't have any experience using CSS variables, but it seems like this should work.

@Conduitry
Copy link
Member

Here's how css-tree parses that. The value of the custom property declaration has type: 'Raw', and has no children array, and so an error is thrown here. We could try skipping minifying the value in that case - or maybe we could just .trim() it. I've never used CSS custom properties either, so I haven't thought about what sorts of transforming is safe to do on the value.

@colah
Copy link
Author

colah commented Aug 8, 2017

Skipping or .trim() both seem like reasonable places to start. :)

(My actual use case involves setting a variable to length values, and I think the other common use case is a color value. Seems like there probably isn't a huge amount to win in trying to minify it.)

Rich-Harris added a commit that referenced this issue Aug 29, 2017
handle css vars in <style> tags
@Rich-Harris
Copy link
Member

Fixed in 1.34 — thanks for the report, sorry for the delay!

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

Successfully merging a pull request may close this issue.

3 participants