Volt.CSS.Modules (Volt v0.9.2)

Copy Markdown View Source

CSS Modules support for .module.css files.

Uses LightningCSS (via Vize) for proper CSS parsing and class name scoping. LightningCSS handles selectors, keyframes, custom identifiers, composes, nested rules, and all other CSS constructs correctly.

Example

Given button.module.css:

.primary { color: blue }
.large { font-size: 2em }

Produces scoped CSS and a JS module exporting the name mapping:

export default {"primary":"ewq3O_primary","large":"ewq3O_large"}

Summary

Functions

Compile a CSS Module file.

Check if a file path is a CSS Module.

Functions

compile(source, filename, opts \\ [])

@spec compile(String.t(), String.t(), keyword()) :: {:ok, String.t(), String.t()}

Compile a CSS Module file.

Returns {:ok, js_code, scoped_css} where js_code exports the class name mapping and scoped_css has LightningCSS-rewritten names.

css_module?(path)

@spec css_module?(String.t()) :: boolean()

Check if a file path is a CSS Module.