Lightning CSS is a high performance CSS parser, transformer and minifier written in Rust. It supports parsing and transforming many modern CSS features into syntax supported by target browsers, and also provides a better compression ratio.
The Lightning CSS plugin will use lightningcss-loader
to replace the builtin postcss-loader
in Rsbuild to reduce the performance overhead of PostCSS and autoprefixer.
You can install the plugin using the following command:
You can register the plugin in the rsbuild.config.ts
file:
After enabling Lightning CSS as a transformer, PostCSS-based configurations and features will not be available, such as tools.postcss
, tools.autoprefixer
and Tailwind CSS. The problem of not being able to be used with Tailwind CSS is expected to be resolved in Tailwind CSS V4 in the future.
Use lightningcss-loader
instead of Rsbuild's builtin postcss-loader
to transform CSS files. For options passed to lightningcss-loader
, please refer to the lightningcss Repo for detailed usage.
false | lightningcss.TransformOptions<CustomAtRules>
lightningcss-loader
only in the development build, still use postcss-loader
in the production buildUsed to inject lightningcss instance. This configuration can be used when a lightningcss instance has been installed and exists in the project.
typeof import('lightningcss')