file_filter.ts

File filtering utilities for CSS class extraction.

view source

Declarations
#

4 declarations

FileFilter
#

file_filter.ts view source

FileFilter import type {FileFilter} from '@fuzdev/fuz_css/file_filter.js';

Filter function to determine which files to process for CSS class extraction. The generators pass each file's absolute id and the project root (Vite's root, Gro's project_root), so a filter can judge a path by where it sits in the project rather than where the project sits on disk. A filter that ignores the root keeps working.

(call)

type (path: string, root: string): boolean

path

type string

root

type string
returns boolean

filter_file_default
#

file_filter.ts view source

(path: string, root: string): boolean import {filter_file_default} from '@fuzdev/fuz_css/file_filter.js';

Default file filter for CSS class extraction. Includes .svelte, .html, .ts, .js, .tsx, .jsx files, and .css files for their variable references (see is_css_file) - except a CSS id with a query, like the Foo.svelte?svelte&type=style&lang.css id of a Svelte component's styles, which its .svelte file already covers. Excludes test files (.test.ts, .spec.ts) and generated files (.gen.ts). Excludes files in test directories (test/, tests/, __tests__/, __mocks__/), judged inside the project or the dependency's package (see to_filter_scope), so a project checked out under a test/ directory still extracts.

path

type string

root

type string

returns

boolean

is_css_file
#

file_filter.ts view source

(path: string): boolean import {is_css_file} from '@fuzdev/fuz_css/file_filter.js';

Whether a file is CSS, which is scanned for the var(--*) references it makes but has no classes or elements to extract.

path

a file id or path

type string

returns

boolean

to_filter_scope
#

file_filter.ts view source

(path: string, root: string): string import {to_filter_scope} from '@fuzdev/fuz_css/file_filter.js';

The part of a file id the default filter's directory checks look at: the path inside its package for a dependency (after node_modules/<pkg>/ or node_modules/@scope/pkg/), the root-relative path for a project file, and the id unchanged outside both (a linked package or a sibling workspace, which a custom filter can judge on its own terms).

path

an absolute file id, or an already relative path

type string

root

the project root, with or without a trailing slash; '' for none

type string

returns

string

the package-relative, root-relative, or unchanged path

Imported by
#