Skip to content

PostCSS plugins #11

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

PostCSS plugins #11

wants to merge 3 commits into from

Conversation

grossbart
Copy link

This PR shows two things:

  • How to be able to specify hover states using postcss-nested. The ability to do so was removed in PR Postcss renderer #10, as the syntax to do so was somewhat custom to Styling. The PostCSS Nested syntax is, of course, also non-standard, but widely used in other pre-processors.
  • That adding additional PostCSS plugins works, but that it is an additional step in the pipeline.

This works well for our usecase, but I'd be interested in your vision for Styling with regards to how many things it should do. For example:

  • Should Styling use the nesting plugin by default?
  • Should Styling be able to use PostCSS plugins specified with the postcss: {} key in the Webpack config without having to specify PostCSS as an additional loader? This would be more efficient, but maybe not as discoverable and a bit surprising.

I'd be happy to adjust this PR with your feedback. Thanks!

renderStyling was mostly concerned with transforming a JS object into a CSS string. Because it used a simple approach, it wasn't able to handle special cases. By using PostCSS we can completely ignore the aspect of how to parse a JS object into a valid CSS string plus have the option to use a number of PostCSS plugins later on.

So yes, this introduces an additional dependency, but it should be worth it, as it further standardizes CSS in JS.
This example shows how additional Postcss plugins can be used by using the Postcss loader and specifying plugins it should use.

This is likely an unnecessary step, because Postcss will run twice with this setup. Instead, it should be possible to specify Postcss plugins that Styling should use directly when it does the transformation.
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.

1 participant