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§
- CssImport
Source - A CSS import source with both the literal source and fallow’s resolver-normalized form.
- Theme
Scan - Result of scanning a CSS source for Tailwind v4
@themeblocks. - Theme
Token Def - A Tailwind v4
@themetoken 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
@applydirective 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!importanttoken are stripped, so a theme token whose utility is applied only via@applyis 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@applydirective. 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/@pluginsource paths from a CSS/SCSS string. - extract_
css_ imports - Extract normalized
@import/@use/@forward/@pluginsource 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@themeblock interior:(name, line)per read, with the--stripped from the name.@theme- interior reads are deliberately excluded here (they are located separately byscan_theme_blocksas the distincttheme-varsurface), so the two read kinds never double-count. Comments / strings /url()are masked first, so avar()inside those regions is never matched. - scan_
theme_ blocks - Scan a CSS source for Tailwind v4
@themeblocks, returning the defined design tokens plus the custom properties read viavar()inside those blocks.