You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In an effort to simplify how I write CSS, I have decided to try ditching preprocessors and support native CSS going forward. This means all the newest features should be supported, such as nesting, relative color syntax, or color spaces like P3.
I now understand that Vite defaults to using PostCSS for transpiling the stylesheets, and the concatenation as well as minification work mostly as expected. I am also interested in what LightningCSS provides and think it could be a better solution.
Assuming this snippet of native CSS doesn't need any preprocessing and should support Firefox/Chrome 125 as of June 2024:
I'd expect vendor prefixes to disappear
No nested CSS rules would need to be flattened
.foo{background:#ff0;border-radius:2px;transition:background .2s;&.bar{color:green}}@media ((color) or (hover)) and (width>1024px){.a{color:green}}
In most ways, the above is truly just a 1:1 minification, and that's basically what I want to see after running the build process. Assuming sourcemap: 'inline' is enabled in the build object, I should also be able to have a tree structure of CSS files that correctly show the original source file for a rule.
How do I accomplish this? I cannot see that Vite has direct support for browserslist. I tried it in three places:
package.json
vite.config.js as an import and inside of css.targets
.browserslistrc
None of the above affected the build file for the CSS.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In an effort to simplify how I write CSS, I have decided to try ditching preprocessors and support native CSS going forward. This means all the newest features should be supported, such as nesting, relative color syntax, or color spaces like P3.
I now understand that Vite defaults to using PostCSS for transpiling the stylesheets, and the concatenation as well as minification work mostly as expected. I am also interested in what LightningCSS provides and think it could be a better solution.
I'll take LightningCSS's playground code as an example:
Assuming this snippet of native CSS doesn't need any preprocessing and should support Firefox/Chrome 125 as of June 2024:
In most ways, the above is truly just a 1:1 minification, and that's basically what I want to see after running the build process. Assuming
sourcemap: 'inline'is enabled in the build object, I should also be able to have a tree structure of CSS files that correctly show the original source file for a rule.How do I accomplish this? I cannot see that Vite has direct support for
browserslist. I tried it in three places:package.jsonvite.config.jsas an import and inside ofcss.targets.browserslistrcNone of the above affected the build file for the CSS.
Maybe I'm just missing something?
https://lightningcss.dev/transpilation.html#browser-targets
https://vitejs.dev/guide/features#lightning-css
Beta Was this translation helpful? Give feedback.
All reactions