-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Preprocess future-proof CSS features #130
Comments
There's an ongoing discussion about this in #78! The TL;DR by @gaearon about cssnext is:
|
That one is a more broad topic since it is about adding support for SASS/Less. Regarding cssnext, yep I agree that "there’s a lot of stuff there" – if we want to play it safe we could just add imports, variables (custom properties), calc, custom-media and autoprefixer. Anyway I am fine with waiting and see where #78 goes. |
We are open to add transpilation for standardized features if those tools don't have large issue lists. We don't want to recommend broken tools by default. |
Since #78 has gone a little bit too broad, let’s use this issue for specific proposals about PostCSS plugins that are safe to enable, work great, correspond to stable specs, and give at least some of the features people want. |
StableTBDN.B. the plugins below don't support dynamic custom properties i.e. cp are compiled to static values.
Personally I also use postcss-autoreset and Stylelint but those require custom configuration. |
My 2 cents:
I am myself using CSS-in-JS (via RN-web) and avoid CSS when possible. |
I'd love to see |
I would strongly advise to take caution with CSS custom properties, and if something like Here's a trivial example of a potential issue: :root {
--foo: green;
}
header {
--foo: red;
}
h1 {
color: var(--foo);
} What color is Keep in mind: all major browsers (except IE and Edge, where it is in progress) support CSS Custom Properties. |
I like this feature: https://github.com/postcss/postcss-media-minmax @media screen and (width >= 500px) and (width <= 1200px) {
.bar {
display: block;
}
} Polyfill is very stable. Spec is a official draft: https://drafts.csswg.org/mediaqueries/#mq-range-context Feature is pretty useful, because it is always hard to work with |
|
I think this plugin is mush-have: https://github.com/postcss/postcss-color-function
|
|
|
Like me and @taion noted in #78, there are few that aren't/can't be to spec, or actively allow non-spec behavior. In particular the |
As @davidkpiano and @jquense note above, most of the more useful cssnext features have significant caveats.
cssnext is very cool, but it's not like Babel in that the features it transpiles are transpiled in a manner that is close enough to spec compliant to "just work". Some of the smaller polyfills in there might be nice, but the "big" ones have meaningful caveats attached. |
The capsule summary is that, for people not paying close attention to the actual spec, Babel loose mode is order of magnitudes safer than the majority of new features enabled by cssnext, and CRA isn't even using that: #198 |
the only thing that I really would like to see are so my vote goes for https://github.com/MadLittleMods/postcss-css-variables |
They're not variables, they're custom properties – and as the repo you mentioned notes, they can't be correctly polyfilled, so you end up with support for either an odd arbitrary subset, or non-spec-compliant behavior that you're actually likely to run into (unlike with Babel). It's not at all a reasonable default. |
@jquense could you please open a issue in |
I agree with you, that CSS specs are not so stable to have future-proof plugins (Custom Media removing change my mind), but don’t be so toxic about speaking of all PostCSS. Autoprefixer is rock solid and no big knowing issue and using it is a great idea on any level ;). CSS Modules works great too and definitely don’t have “tons of issues” PostCSS is not only “cssnext” stuff. There are many other tools, which works great. And Other great tool that could be implemented in zero-config app is a Stylelint — it has non-codestyle rules to avoid mistakes. |
@ai My goal is not to be toxic, it's to be relevant to CRA requirements. Obviously there is some good in PostCSS :) Except Styelint with a small config (even the styelint-config-standard include stylistic rules) and Autoprefixer, I don't think something will be the right fit for CRA. |
Should we use github's reactions to decide what to do about this issue? I would suggest to use ±1 (thumb up/down) on this comment to decide if we want to:
cc @gaearon |
No config, means no config. I am pretty sure nobody want to add config just to support the (not really mature) PostCSS ecosystem :/ |
@MoOx I don't have strong opinions, I just think that we shouldn't discuss if PostCSS is good|bad|stable|unstable forever :) fwiw 2) would be an add-on only feature i.e. if you want to configure postcss you have a way to do so otherwise continue to do what you were doing :) fwiw2 I also think that in the long run css-in-js will win so shurg |
I agree that “no config” means no config”.
@MoOx don’t be toxic. If cssnext plugins is not really mature, doesn’t mean that other plugins are not really mature. Stylelint, Autoprefixer, PostCSS Assets and CSS Modules show a great example of mature ecosystem. It is especially painful to hear “not really mature” from your, because you a maintainer of cssnext, and esosystem problems in cssnext is on you. Don’t spread cssnext’s lack of maintaibility to other well maintained plugins. |
Let's find a solution that works for everybody No config means no configWell, then don't force the package to lookup something and have predefined PostCSS plugins that only are well maintained and curated. Config, Hurrah!Just add a parameter that is a Javascript file, arguments could be many things open to people who know more than me, where you could whatever Javascript allow you to do 😄 @giuseppeg I support both cases, 0 config and advance user, because I really dont want to lose the flexibility of adding some good stuff like @ai called, so |
Anyway I think that we could close this issue. Main topic was about future-proof plugins. As was shown CSS specs are not so stable as ES2016 was in 2015, so plugins (even very well done with good support) could not be future-proof for zero-config case of CRA. @yordis maybe you should open a separated issue about config. |
I would prefer @gaearon to open a new issue if need it. The core contributors have the final word on this. |
For design-led websites - which is a lot of websites, and what I make all day - unfortunately I can't use this amazing, maintained, JS build tool if it doesn't support SASS, or any kind of CSS betterer. 😔 If I could hook my own CSS (and other asset) build tools in with this somehow, and have the browser update with changes, I'd find a way to make it work. |
It supports SASS in the exactly same way people have been using SASS for years. Run a console SASS watcher, and import the resulting CSS from your JS files. |
Thank you, I ended up using gulp to build all my non-js tasks. For SASS, I compile to
and everything works great. |
@gaearon I feel like that we can close this issue unless you want to implement this thing |
@daviestar do you have one css file per component then? Or just a single massive |
@tonyxiao I put SASS files in with my components, but as I said above I don't really agree I should import them into JS as IMO, CSS doesn't work that way. I can easily avoid it by compiling all my SASS files to one CSS file at the root using gulp, then just import that so webpack picks it up in development. |
Got it, thanks a pretty workable approach if you just completely avoid importing css into js. thanks for sharing @daviestar |
Let’s close as there is no consensus and I don’t feel comfortable proceeding with this. |
That Sassy nesting has finally been fixed. |
FYI, I deprecated cssnext in favor of postcss-preset-env, you might want to think about this one that offers stages like babel-preset-env! |
Yeap. With |
We run |
I’d love to share this with my family and friends. I wrote PostCSS Preset Env, the tool you are using to future proof CSS. I hope it’s not presumptuous to ask, but might it earn a mention or thanks in the blog notes, @gaearon? https://reactjs.org/blog/2018/10/01/create-react-app-v2.html |
We should probably include it into the notes. I forgot. |
Would you be open to add a few future-proof PostCSS plugins to transpile things like custom properties, calc, custom media queries?
This could be as simple as using the postcss-cssnext plugin or set up a lil preprocessor like we did for suitcss.
If there is interest I can probably help out.
The text was updated successfully, but these errors were encountered: