-
Notifications
You must be signed in to change notification settings - Fork 90
A notice to cssnext users #32
Comments
@jonathantneal: Babel looks to be dropping stage 0 - 2 when babel 7 releases (For reasoning see: babel/babel#7770). I agree with their reasoning and think doing the same here would be a good idea (still include stage 0 - 2 features in preset-env but only expose them through the features option). What do you think? Doing that after release would probably annoy a great many people. |
@Lysholm, thanks for bringing that to my attention. I have certain disagreements with the suggestion in that issue, based upon The Extensible Web Manifesto, and I’ve shared them back. |
@jonathantneal: I see your point but i think we have different high level preferences. Regardless of available stages, suggesting that everyone opt in for stage: 0 seems to invite misuse. Maybe suggest stage: 2 + nesting? Not that users of cssnext aren't used to it, looking at |
@jonathantneal I have the current configuration of cssnext: postcss.config.js
I couldn't find a migration guide to help me move to postcss-preset-env since just replacing the module isn't working. What do I need to do to make this work with your module? |
Great question, @pietrofxq. PostCSS Preset Env will takes options by the feature name. See https://github.com/csstools/postcss-preset-env#features postcssPresetEnv({
features: {
'custom-properties': {
variables: require('./src/css/variables')
},
'custom-media-queries': {
extensions: require('./src/css/medias')
}
}
}) To benefit others, here is a list of PostCSS Preset Env options compared with cssnext options:
|
@jonathantneal Thanks, the variables are being recognized now. However, looks like the original statement with the variable isn't being removed: Do I need to implement something else to fix this? (I don't have this issue with cssnext) |
@pietrofxq CSSnext was using an older versions of |
My team found it rather hard to determine which stage to use – or whether it would be easier to stay with a certain stage and enable some features specifically. So I ended up with a table of
Here you go:
We went with stage 2 and enabling I threw all of this into a gist as well: https://gist.github.com/HerrBertling/fd69dcb5664eeb5543b761115d8b9ece |
Nice work, @HerrBertling. There are a lot of options, so I can see how this table you’ve created missed some from my original table. rebeccapurple => rebeccapurple-color And for all color functional notation => color-functional-notation Some of the other items that were removed were already being removed from cssnext because they were rejected specs, or targeted very old browsers, or were optimizations not really related to the future. EDIT: If you would, I’d prefer you fix your table above this comment, while my corrections can linger here for history-sake. |
Perfect, thanks :) Regarding the old, outdated features, I already thought so. Especially for the |
just noticed that for postcss.config.js , we should be calling the plugin like
Right?? |
The readme says: postcssPresetEnv({
/* use stage 3 features + css nesting rules */
stage: 3,
features: {
'nesting-rules': true
}
}) |
Tried a few of the suggestions here, but cannot get Rollup config: {
plugins: [
postcssImport(),
postcssUrl(urlOptions),
postcssPresetEnv({
stage: 0
})
]
} Input: .button {
--button-border-color--base: #c4cacf;
padding: 8px 12px;
line-height: 1;
border: 1px solid var(--button-border-color--base);
background-color: transparent;
border-radius: 3px;
transition: all 0.3s ease 0s;
} Output: .button {
padding: 8px 12px;
line-height: 1;
border: 1px solid var(--button-border-color--base);
border: 1px solid var(--button-border-color--base);
background-color: transparent;
border-radius: 3px;
transition: all 0.3s ease 0s
} |
For brave souls - to reduce
|
@killtheliterate You must declare your custom properties in a Also adding |
@pascalduez heya, thanks for the tip—I resolved the immediate issue by using
This does lead to many duplicate declarations of Using the form
|
Hi, thanks for this documentation, it's made transitioning a much smoother process. One outstanding question, is there a pre-existing plugin to transform color() to color-mod() or am I stuck writing my own until I can convert my source code to use color-mod? |
@spnc-omz, there is not an existing plugin to transform the pre-2015 |
@jonathantneal thanks for the response. While awaiting a response I wrote a quick plugin to inline within my config that would update those. We’re working through rewriting our source now to alleviate that need. I can share the source if anyone would find it beneficial. |
@jonathantneal I think the POSTCSS Preset Env option list campared with the nextcss options should be in the documentation. I searched 30 minutes how to set media queries option in stage 3 cause the option naming have changed and could be found nowhere else. In my opinion this is not an issue topic. This info should be globally accessible without searching. |
Folks can still reference this thread, but I will be closing it as an active issue. |
affects: @goldwasserexchange/postcss-config postcss-cssnext is deprecated and should be replaced with postcss-preset-env see https://moox.io/blog/deprecating-cssnext/ and csstools/postcss-preset-env#32 ISSUES CLOSED: #27
affects: @goldwasserexchange/postcss-config postcss-cssnext is deprecated and should be replaced with postcss-preset-env see https://moox.io/blog/deprecating-cssnext/ and csstools/postcss-preset-env#32 ISSUES CLOSED: #27
@jonathantneal how do you "require" (import) you custom-media and/or custom-properties (vars), like mentioned in #32 (comment) when using |
I am working on that. It’s not a done feature and my time is limited. I’ve finished this work for Custom Selectors. I have a PR open for Custom Media. I have not started the work for Custom Properties. |
gulp build-css is now an npm script `npm run build-css`. postcss-cssnext was deprecated so it has been replaced with several postcss plugins. See: https://moox.io/blog/deprecating-cssnext/ csstools/postcss-preset-env#32
This was deprecated a few years ago, and appears to be causing issues with a newer (postcss v8) api. https://moox.io/blog/deprecating-cssnext csstools/postcss-preset-env#32 This appears to fix #14052 but was tested only by observing that the postcss command no longer fails with an error, and not that browser ready css is generated from the input or working for users. It's likely that the next step is to add back postcss-preset-env (which does not include postcss-calc, which was I think related to the broken parses and calling the older version of postcss internally).
A third of a million weekly cssnext installs are about to get a deprecation notice redirecting them PostCSS Preset-Env, so let me explain what this project is, and what you need to know if you use cssnext.
What is PostCSS Preset-Env
PostCSS Preset-Env is a bundle of CSS polyfills and prollyfills applied at compile time. It is like Babel Preset-Env for CSS. And like Babel, there are less stable and more stable features you can use, but only the safer features are polyfilled by default. Related: The PostCSS Preset-Env homepage.
About features and changes
Disabling unstable features by default is an important departure from cssnext, and the change is to protect you and your team. This is because unstable features may change or disappear over time.
What should cssnext users do? They should take advantage of “stages”. Related: The cssdb staging process.
Like Babel, you can choose less stable or more stable features by specifying a “stage”. The stages are 0 - 4. The lower the stage number, the less stable the feature. Babel stages follow the TC39 staging process, and PostCSS stages follow the cssdb staging process.
cssnext users have been using many “Stage 0” features, and so the smoothest transition for your team may be to enable Stage 0 at first. Note: Nesting Rules are a Stage 0 feature.
Now, unlike Babel, PostCSS stages are not yet endorsed by or affiliated with a specification committee or browser vendor. If and when they are, that committee would likely be the CSSWG. I am actively trying to establish a partnership with them. Related: An issue to update cssdb with CSSWG feedback.
About browser support
Both Babel and PostCSS support a “browserslist”, which is a sharable configuration that determines the browsers your project is supporting. Babel and PostCSS use this configuration to omit polyfills for features that your target browsers already support.
About these projects
Babel and PostCSS were created to help developers accomplish real things with modern and emerging technologies. Both projects provide a great way for developers, authors, and implementors to communicate, thus improving the creation of standards, testing, feedback, and new use cases.
You can try PostCSS Preset-Env in the browser right now, and I hope you’ll consider using it in your next project. Thanks!
The text was updated successfully, but these errors were encountered: