Migrate to Lightning CSS
1 minute read
Replace the current PostCSS pipeline with Lightning CSS. Lightning CSS is a fast CSS parser, transformer, and minifier written in Rust, with built-in support for nesting, custom media queries, and modern CSS features without needing separate plugins.
Motivation
- Significantly faster CSS processing (Rust-based)
- Native support for CSS nesting, no plugin needed
- Built-in vendor prefixing and browser target support
- Vite has built-in Lightning CSS integration
- Reduce dependency count by removing PostCSS plugins
Tasks
- Enable
css.lightningcssinvite.config.js - Replace
postcss-nested-propsusage with standard CSS nesting - Replace
postcss-simple-varswith CSS custom properties - Replace
postcss-easy-importwith native CSS imports - Remove
postcss-preset-env(Lightning CSS handles transforms) - Remove
postcss.config.cjs - Update
svelte-preprocessconfig if needed - Test all component styles for regressions
Risks
postcss-nested-propsshorthand has no direct equivalent in Lightning CSS — need to expand manuallypostcss-simple-vars($varsyntax) needs migrating tovar(--var)- Some edge cases in nesting behavior may differ between PostCSS and Lightning CSS
Read next