Skip to main content

Module bundler

Module bundler 

Source
Available on crate feature bundler only.
Expand description

CSS bundling.

A Bundler can be used to combine a CSS file and all of its dependencies into a single merged style sheet. It works together with a SourceProvider (e.g. FileProvider) to read files from the file system or another source, and returns a StyleSheet containing the rules from all of the dependencies of the entry file, recursively.

Rules are bundled following @import order, and wrapped in the necessary @media, @supports, and @layer rules as appropriate to preserve the authored behavior.

§Example

use std::path::Path;
use lightningcss::{
  bundler::{Bundler, FileProvider},
  stylesheet::ParserOptions
};

let fs = FileProvider::new();
let mut bundler = Bundler::new(&fs, None, ParserOptions::default());
let stylesheet = bundler.bundle(Path::new("style.css")).unwrap();

Structs§

Bundler
A Bundler combines a CSS file and all imported dependencies together into a single merged style sheet.
FileProvider
Provides an implementation of SourceProvider that reads files from the file system.

Enums§

BundleErrorKind
An error that could occur during bundling.
ResolveResult
The result of SourceProvider::resolve.

Traits§

SourceProvider
A trait to provide the contents of files to a Bundler.