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

Plugging in CSS preprocessor in component files #20

Open
p3k opened this issue Jun 21, 2018 · 2 comments
Open

Plugging in CSS preprocessor in component files #20

p3k opened this issue Jun 21, 2018 · 2 comments

Comments

@p3k
Copy link
Collaborator

p3k commented Jun 21, 2018

What would be the best way to enable CSS dialects like LESS or SASS in a component file’s <style> element?

Example (LESS):

<div class='foo'>Hello, World!</div>

<style>
  @color: yellow;

  .foo {
    background-color: @color;
  }
</style>

The content’s of the <style> element should then be compiled to this (and then of course further processed as scoped component CSS):

.foo {
  background-color: yellow;
}
@fskreuz
Copy link
Contributor

fskreuz commented Jun 21, 2018

With the tools we currently have, rcu should be able to facilitate this. rcu.parse is the function you're looking for. It extracts the templates (pre-parsed), styles and scripts (both untouched) from the component file. You can then compile the styles and use the compiled output for the component css.

Tools like ractiveify have already attempted to do this. It does this by adding type on <style> and <script> to tell the tool that the contents of <style> and <script> aren't vanilla CSS and JS.

@p3k
Copy link
Collaborator Author

p3k commented Jun 21, 2018

Thanks for the pointer to ractiveify! That looks exactly like what I am looking for 😺

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

2 participants