MCPcopy
hub / github.com/tailwindlabs/tailwindcss / compile

Function compile

packages/tailwindcss/src/index.ts:820–856  ·  view source on GitHub ↗
(
  css: string,
  opts: CompileOptions = {},
)

Source from the content-addressed store, hash-verified

818export type { DecodedSourceMap }
819
820export async function compile(
821 css: string,
822 opts: CompileOptions = {},
823): Promise<{
824 sources: { base: string; pattern: string; negated: boolean }[]
825 root: Root
826 features: Features
827 build(candidates: string[]): string
828 buildSourceMap(): DecodedSourceMap
829}> {
830 let ast = CSS.parse(css, { from: opts.from })
831 let api = await compileAst(ast, opts)
832 let compiledAst = ast
833 let compiledCss = css
834
835 return {
836 ...api,
837 build(newCandidates) {
838 let newAst = api.build(newCandidates)
839
840 if (newAst === compiledAst) {
841 return compiledCss
842 }
843
844 compiledCss = toCss(newAst, !!opts.from)
845 compiledAst = newAst
846
847 return compiledCss
848 },
849
850 buildSourceMap() {
851 return createSourceMap({
852 ast: compiledAst,
853 })
854 },
855 }
856}
857
858export async function __unstable__loadDesignSystem(css: string, opts: CompileOptions = {}) {
859 let result = await parseCss(CSS.parse(css, { from: opts.from }), opts)

Callers 10

at-import.test.tsFile · 0.90
renderFunction · 0.90
index.test.tsFile · 0.70
index.bench.tsFile · 0.70
prefix.test.tsFile · 0.70
utilities.test.tsFile · 0.70
plugin-api.test.tsFile · 0.50
config.test.tsFile · 0.50
runFunction · 0.50
runFunction · 0.50

Calls 1

compileAstFunction · 0.70

Tested by 2

renderFunction · 0.72
runFunction · 0.40