Crate lightningcss

source ·
Expand description

Lightning CSS is a CSS parser, transformer, and minifier based on the cssparser crate used in Firefox. It supports fully parsing all CSS rules, properties, and values into normalized structures exactly how a browser would. Once parsed, the CSS can be transformed to add or remove vendor prefixes, or lower syntax for older browsers as appropriate. The style sheet can also be minified to merge longhand properties into shorthands, merge adjacent rules, reduce calc() expressions, and more. Finally, the style sheet can be printed back to CSS syntax, either minified to remove whitespace and compress the output as much as possible, or pretty printed.

The StyleSheet struct is the main entrypoint for Lightning CSS, and supports parsing and transforming entire CSS files. You can also parse and manipulate individual CSS rules, properties, or values. The bundler module also can be used to combine a CSS file and all of its dependencies together into a single style sheet. See the individual module documentation for more details and examples.


CSS bundling.
CSS module exports.
CSS declarations.
Dependency analysis.
Error types.
Media queries.
CSS serialization and source map generation.
CSS property values.
CSS rules.
CSS selectors.
CSS style sheets and style attributes.
Browser target options.
Traits for parsing and serializing CSS.
Common CSS values used across many properties.
Vendor prefixes.
Visitors for traversing the values in a StyleSheet.


Constructs a constant VisitTypes from flags.