Home / Function/ compile() — tailwindcss Function Reference

compile() — tailwindcss Function Reference

Architecture documentation for the compile() function in index.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  38bfe51e_e2b6_fcde_5ec2_9e78b758e748["compile()"]
  1f9197e1_4bbd_21b6_da7e_de2319e5ff8f["createCompiler()"]
  1f9197e1_4bbd_21b6_da7e_de2319e5ff8f -->|calls| 38bfe51e_e2b6_fcde_5ec2_9e78b758e748
  b5593eac_57a1_0ee5_929c_ee4793c6003c["compile()"]
  b5593eac_57a1_0ee5_929c_ee4793c6003c -->|calls| 38bfe51e_e2b6_fcde_5ec2_9e78b758e748
  3bd0a797_6dde_5feb_e059_8147dc714584["run()"]
  3bd0a797_6dde_5feb_e059_8147dc714584 -->|calls| 38bfe51e_e2b6_fcde_5ec2_9e78b758e748
  03cdd11e_2ae7_a373_7130_c6663e810fd9["render()"]
  03cdd11e_2ae7_a373_7130_c6663e810fd9 -->|calls| 38bfe51e_e2b6_fcde_5ec2_9e78b758e748
  253418a1_4f08_cf0e_5b8e_c6392b9959eb["parse()"]
  38bfe51e_e2b6_fcde_5ec2_9e78b758e748 -->|calls| 253418a1_4f08_cf0e_5b8e_c6392b9959eb
  f5e443d2_a934_36af_23f2_b1c002aaa585["compileAst()"]
  38bfe51e_e2b6_fcde_5ec2_9e78b758e748 -->|calls| f5e443d2_a934_36af_23f2_b1c002aaa585
  e7a34553_0273_6202_4792_07409e33d8f0["toCss()"]
  38bfe51e_e2b6_fcde_5ec2_9e78b758e748 -->|calls| e7a34553_0273_6202_4792_07409e33d8f0
  5ab956da_909b_1c7e_21c8_9cf5b074e2ba["createSourceMap()"]
  38bfe51e_e2b6_fcde_5ec2_9e78b758e748 -->|calls| 5ab956da_909b_1c7e_21c8_9cf5b074e2ba
  style 38bfe51e_e2b6_fcde_5ec2_9e78b758e748 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/index.ts lines 819–855

export async function compile(
  css: string,
  opts: CompileOptions = {},
): Promise<{
  sources: { base: string; pattern: string; negated: boolean }[]
  root: Root
  features: Features
  build(candidates: string[]): string
  buildSourceMap(): DecodedSourceMap
}> {
  let ast = CSS.parse(css, { from: opts.from })
  let api = await compileAst(ast, opts)
  let compiledAst = ast
  let compiledCss = css

  return {
    ...api,
    build(newCandidates) {
      let newAst = api.build(newCandidates)

      if (newAst === compiledAst) {
        return compiledCss
      }

      compiledCss = toCss(newAst, !!opts.from)
      compiledAst = newAst

      return compiledCss
    },

    buildSourceMap() {
      return createSourceMap({
        ast: compiledAst,
      })
    },
  }
}

Domain

Subdomains

Frequently Asked Questions

What does compile() do?
compile() is a function in the tailwindcss codebase.
What does compile() call?
compile() calls 4 function(s): compileAst, createSourceMap, parse, toCss.
What calls compile()?
compile() is called by 4 function(s): compile, createCompiler, render, run.

Analyze Your Own Codebase

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

Try Supermodel Free