Home / Function/ resolve_globs() — tailwindcss Function Reference

resolve_globs() — tailwindcss Function Reference

Architecture documentation for the resolve_globs() function in detect_sources.rs from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  35f1489c_702c_3634_4244_4ac0a952da39["resolve_globs()"]
  7d2319d3_25b0_c592_4c61_1dd3bd91bb9a["detect_sources.rs"]
  35f1489c_702c_3634_4244_4ac0a952da39 -->|defined in| 7d2319d3_25b0_c592_4c61_1dd3bd91bb9a
  style 35f1489c_702c_3634_4244_4ac0a952da39 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/scanner/detect_sources.rs lines 31–161

pub fn resolve_globs(
    base: PathBuf,
    dirs: &[PathBuf],
    extensions: &FxHashSet<String>,
) -> Vec<GlobEntry> {
    let allowed_paths: FxHashSet<PathBuf> = FxHashSet::from_iter(dirs.iter().cloned());

    // A list of known extensions + a list of extensions we found in the project.
    let mut found_extensions: FxHashSet<String> =
        FxHashSet::from_iter(KNOWN_EXTENSIONS.iter().map(|x| x.to_string()));
    found_extensions.extend(extensions.iter().cloned());

    // A list of directory names where we can't use globs, but we should track each file
    // individually instead. This is because these directories are often used for both source and
    // destination files.
    let forced_static_directories: FxHashSet<PathBuf> =
        FxHashSet::from_iter(vec![base.join("public")]);

    // All directories where we can safely use deeply nested globs to watch all files.
    // In other comments we refer to these as "deep glob directories" or similar.
    //
    // E.g.: `./src/**/*.{html,js}`
    let mut deep_globable_directories: FxHashSet<PathBuf> = Default::default();

    // All directories where we can only use shallow globs to watch all direct files but not
    // folders.
    // In other comments we refer to these as "shallow glob directories" or similar.
    //
    // E.g.: `./src/*/*.{html,js}`
    let mut shallow_globable_directories: FxHashSet<PathBuf> = Default::default();

    // Collect all valid paths from the root. This will already filter out ignored files, unknown
    // extensions and binary files.
    let mut it = WalkDir::new(&base)
        .sort_by(sort_by_dir_and_name)
        .into_iter();

    // Figure out all the shallow globable directories.
    while let Some(Ok(entry)) = it.next() {
        let path = entry.path();
        if !path.is_dir() {
            continue;
        }

        if !allowed_paths.contains(path) {
            let mut path = path;
            while let Some(parent) = path.parent() {
                if parent == base {
                    break;
                }

                shallow_globable_directories.insert(parent.to_path_buf());
                path = parent
            }

            it.skip_current_dir();
        }
    }

    // Figure out all the deep globable directories.
    let mut it = WalkDir::new(&base)
        .sort_by(sort_by_dir_and_name)
        .into_iter();

    while let Some(Ok(entry)) = it.next() {
        let path = entry.path();
        if path.is_file() {
            continue;
        }

        if path == base {
            continue;
        }

        if IGNORED_CONTENT_DIRS
            .iter()
            .any(|dir| match path.file_name() {
                Some(name) => name == *dir,
                None => false,
            })
        {

Domain

Subdomains

Frequently Asked Questions

What does resolve_globs() do?
resolve_globs() is a function in the tailwindcss codebase, defined in crates/oxide/src/scanner/detect_sources.rs.
Where is resolve_globs() defined?
resolve_globs() is defined in crates/oxide/src/scanner/detect_sources.rs at line 31.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free