{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/static-css/emit/index.ts"],"sourcesContent":["// react-dom/server, @ant-design/cssinjs and antd-style pick their dev/prod flavor\n// at import time and the dev flavor emits different CSS, so production must be\n// forced before any React/antd module loads — hence this entry has no static\n// imports of them and must be imported before anything that does.\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type { AntdStaticCssOptions, AntdStaticCssPayload } from '../buildAntdStaticCss';\nimport type { ThemeVarsCssOptions, ThemeVarsCssPayload } from '../themeVars';\n\nprocess.env.NODE_ENV = 'production';\n\nexport interface EmitStaticCssOptions {\n  antd?: AntdStaticCssOptions | false;\n  manifestPath?: string;\n  outDir: string;\n  themeVars?: ThemeVarsCssOptions | false;\n}\n\nexport interface EmitStaticCssResult {\n  antd?: AntdStaticCssPayload;\n  files: string[];\n  themeVars?: ThemeVarsCssPayload;\n}\n\nexport const emitStaticCssAssets = async (\n  options: EmitStaticCssOptions,\n): Promise<EmitStaticCssResult> => {\n  const { outDir, manifestPath = path.join(outDir, 'static-css.manifest.json') } = options;\n\n  await mkdir(outDir, { recursive: true });\n\n  const result: EmitStaticCssResult = { files: [] };\n  const manifest: Record<string, unknown> = {};\n\n  if (options.antd !== false) {\n    const { buildAntdStaticCss } = await import('../buildAntdStaticCss');\n    const payload = buildAntdStaticCss(options.antd);\n    const file = path.join(outDir, 'antd.css');\n    await writeFile(file, payload.css, 'utf8');\n    result.antd = payload;\n    result.files.push(file);\n    manifest.antd = { hash: payload.hash, href: payload.href, styleKeys: payload.styleKeys };\n  }\n\n  if (options.themeVars !== false) {\n    const { buildThemeVarsCss } = await import('../themeVars');\n    const payload = buildThemeVarsCss(options.themeVars);\n    const file = path.join(outDir, 'theme-vars.css');\n    await writeFile(file, payload.css, 'utf8');\n    result.themeVars = payload;\n    result.files.push(file);\n    manifest.themeVars = { hash: payload.hash, href: payload.href };\n  }\n\n  await writeFile(manifestPath, JSON.stringify(manifest, null, 2), 'utf8');\n  result.files.push(manifestPath);\n\n  return result;\n};\n"],"mappings":";;;AAUA,QAAQ,IAAI,WAAW;AAevB,MAAa,sBAAsB,OACjC,YACiC;CACjC,MAAM,EAAE,QAAQ,eAAe,KAAK,KAAK,QAAQ,0BAA0B,MAAM;CAEjF,MAAM,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;CAEvC,MAAM,SAA8B,EAAE,OAAO,CAAC,EAAE;CAChD,MAAM,WAAoC,CAAC;CAE3C,IAAI,QAAQ,SAAS,OAAO;EAC1B,MAAM,EAAE,uBAAuB,MAAM,OAAO;EAC5C,MAAM,UAAU,mBAAmB,QAAQ,IAAI;EAC/C,MAAM,OAAO,KAAK,KAAK,QAAQ,UAAU;EACzC,MAAM,UAAU,MAAM,QAAQ,KAAK,MAAM;EACzC,OAAO,OAAO;EACd,OAAO,MAAM,KAAK,IAAI;EACtB,SAAS,OAAO;GAAE,MAAM,QAAQ;GAAM,MAAM,QAAQ;GAAM,WAAW,QAAQ;EAAU;CACzF;CAEA,IAAI,QAAQ,cAAc,OAAO;EAC/B,MAAM,EAAE,sBAAsB,MAAM,OAAO;EAC3C,MAAM,UAAU,kBAAkB,QAAQ,SAAS;EACnD,MAAM,OAAO,KAAK,KAAK,QAAQ,gBAAgB;EAC/C,MAAM,UAAU,MAAM,QAAQ,KAAK,MAAM;EACzC,OAAO,YAAY;EACnB,OAAO,MAAM,KAAK,IAAI;EACtB,SAAS,YAAY;GAAE,MAAM,QAAQ;GAAM,MAAM,QAAQ;EAAK;CAChE;CAEA,MAAM,UAAU,cAAc,KAAK,UAAU,UAAU,MAAM,CAAC,GAAG,MAAM;CACvE,OAAO,MAAM,KAAK,YAAY;CAE9B,OAAO;AACT"}