Home / Function/ migrateContent() — tailwindcss Function Reference

migrateContent() — tailwindcss Function Reference

Architecture documentation for the migrateContent() function in migrate-js-config.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  ba8b79fb_a997_a4e8_be72_609168d2be54["migrateContent()"]
  ffe9c87e_35ad_f431_9625_80fc875792a7["migrate-js-config.ts"]
  ba8b79fb_a997_a4e8_be72_609168d2be54 -->|defined in| ffe9c87e_35ad_f431_9625_80fc875792a7
  617e9831_5cd2_4ca6_2c65_f89e3720cfd8["migrateJsConfig()"]
  617e9831_5cd2_4ca6_2c65_f89e3720cfd8 -->|calls| ba8b79fb_a997_a4e8_be72_609168d2be54
  9b03276a_ec42_9755_6ae6_25f04739827f["autodetectedSourceFiles()"]
  ba8b79fb_a997_a4e8_be72_609168d2be54 -->|calls| 9b03276a_ec42_9755_6ae6_25f04739827f
  0e4d550c_52e4_f623_6ab3_6ce178f06903["patternSourceFiles()"]
  ba8b79fb_a997_a4e8_be72_609168d2be54 -->|calls| 0e4d550c_52e4_f623_6ab3_6ce178f06903
  style ba8b79fb_a997_a4e8_be72_609168d2be54 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts lines 341–390

async function migrateContent(
  unresolvedConfig: Config,
  configPath: string,
  base: string,
): Promise<{ base: string; pattern: string }[]> {
  let autoContentFiles = autodetectedSourceFiles(base)

  let sources = []
  let contentIsRelative = (() => {
    if (!unresolvedConfig.content) return false
    if (Array.isArray(unresolvedConfig.content)) return false
    if (unresolvedConfig.content.relative) return true
    if (unresolvedConfig.future === 'all') return false
    return unresolvedConfig.future?.relativeContentPathsByDefault ?? false
  })()

  let sourceGlobs = Array.isArray(unresolvedConfig.content)
    ? unresolvedConfig.content.map((pattern) => ({ base, pattern }))
    : (unresolvedConfig.content?.files ?? []).map((pattern) => {
        if (typeof pattern === 'string' && contentIsRelative) {
          return { base: path.dirname(configPath), pattern: pattern }
        }
        return { base, pattern }
      })

  for (let { base, pattern } of sourceGlobs) {
    if (typeof pattern !== 'string') {
      throw new Error('Unsupported content value: ' + pattern)
    }

    let sourceFiles = patternSourceFiles({
      base,
      pattern: pattern[0] === '!' ? pattern.slice(1) : pattern,
      negated: pattern[0] === '!',
    })

    let autoContentContainsAllSourceFiles = true
    for (let sourceFile of sourceFiles) {
      if (!autoContentFiles.includes(sourceFile)) {
        autoContentContainsAllSourceFiles = false
        break
      }
    }

    if (!autoContentContainsAllSourceFiles) {
      sources.push({ base, pattern })
    }
  }
  return sources
}

Subdomains

Called By

Frequently Asked Questions

What does migrateContent() do?
migrateContent() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts.
Where is migrateContent() defined?
migrateContent() is defined in packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts at line 341.
What does migrateContent() call?
migrateContent() calls 2 function(s): autodetectedSourceFiles, patternSourceFiles.
What calls migrateContent()?
migrateContent() is called by 1 function(s): migrateJsConfig.

Analyze Your Own Codebase

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

Try Supermodel Free