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_apply_tokens_located
Like extract_apply_tokens, but pairs each class-shaped token with the 1-based source line of its @apply directive. Used by the token-consumer reverse index to locate @apply-surface consumers; masking preserves byte offsets so the directive line is recoverable from the match start.
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.
extract_css_var_reads_located
Located regular-CSS var(--token) reads OUTSIDE any @theme block interior: (name, line) per read, with the -- stripped from the name. @theme- interior reads are deliberately excluded here (they are located separately by scan_theme_blocks as the distinct theme-var surface), so the two read kinds never double-count. Comments / strings / url() are masked first, so a var() inside those regions is never matched.
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.