pub struct StyleSheet<'i, 'o> {
    pub rules: CssRuleList<'i>,
    pub sources: Vec<String>,
    pub source_map_url: Option<String>,
    /* private fields */
}
Expand description

A CSS style sheet, representing a .css file or inline <style> element.

Style sheets can be parsed from a string, constructed from scratch, or created using a Bundler. Then, they can be minified and transformed for a set of target browsers, and serialied to a string.

Example

use parcel_css::stylesheet::{
  StyleSheet, ParserOptions, MinifyOptions, PrinterOptions
};

// Parse a style sheet from a string.
let mut stylesheet = StyleSheet::parse(
  r#"
  .foo {
    color: red;
  }

  .bar {
    color: red;
  }
  "#,
  ParserOptions::default()
).unwrap();

// Minify the stylesheet.
stylesheet.minify(MinifyOptions::default()).unwrap();

// Serialize it to a string.
let res = stylesheet.to_css(PrinterOptions::default()).unwrap();
assert_eq!(res.code, ".foo, .bar {\n  color: red;\n}\n");

Fields

rules: CssRuleList<'i>

A list of top-level rules within the style sheet.

sources: Vec<String>

A list of file names for all source files included within the style sheet. Sources are referenced by index in the loc property of each rule.

source_map_url: Option<String>

The source map URL extracted from the original style sheet.

Implementations

Creates a new style sheet with the given source filenames and rules.

Parse a style sheet from a string.

Returns the inline source map associated with the style sheet.

Minify and transform the style sheet for the provided browser targets.

Serialize the style sheet to a CSS string.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

The archived version of the pointer metadata for this type.

Converts some archived metadata to the pointer metadata for itself.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Deserializes using the given deserializer

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type for metadata in pointers and references to Self.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.