Skip to main content

Module css

Module css 

Source
Expand description

CSS/SCSS file parsing and CSS Module class name extraction.

Handles @import, @use, @forward, @plugin, @apply, @tailwind directives, and extracts class names as named exports from .module.css/.module.scss files.

Extraction is a deliberate hybrid, not a half-finished migration. lightningcss owns the membership decision for standard CSS (which .token occurrences are genuine class selectors, via lightningcss_class_set); the regex scanners own span location and the entire SCSS path. lightningcss parses standard CSS only, not SCSS syntax (@use, @forward, // line comments, $variables), so SCSS files are gated away from the parser and the regex chain stays as permanent infrastructure rather than a transitional step toward an all-parser tokenizer.

Structs§

CssImportSource
A CSS import source with both the literal source and fallow’s resolver-normalized form.
ThemeScan
Result of scanning a CSS source for Tailwind v4 @theme blocks.
ThemeTokenDef
A Tailwind v4 @theme token definition: the custom-property name WITHOUT the leading -- (e.g. color-brand) and its 1-based line in the source.

Functions§

extract_apply_tokens
Extract the utility tokens referenced in @apply directive bodies across a CSS source (comment / string masked). @apply rounded-card font-bold; yields ["rounded-card", "font-bold"]. The leading-! and trailing-! important modifiers and a bare !important token are stripped, so a theme token whose utility is applied only via @apply is credited as used.
extract_css_import_sources
Extract @import / @use / @forward / @plugin source paths from a CSS/SCSS string.
extract_css_imports
Extract normalized @import / @use / @forward / @plugin source paths from a CSS/SCSS string.
extract_css_module_exports
Extract class names from a CSS module file as named exports.
scan_theme_blocks
Scan a CSS source for Tailwind v4 @theme blocks, returning the defined design tokens plus the custom properties read via var() inside those blocks.