chore: simplify theme imports in dev (#3851)

This commit is contained in:
Sandro Circi
2025-04-10 15:59:04 +02:00
committed by GitHub
parent 8c68af5e3b
commit fb4c210b41
3 changed files with 8 additions and 6 deletions

View File

@@ -50,12 +50,13 @@ export function getTemplates(options: ModuleOptions, uiConfig: Record<string, an
}
// For local development, import directly from theme
if (process.argv.at(-1) === '--uiDev') {
const isUiDev = true
if (isUiDev) {
const templatePath = fileURLToPath(new URL(`./theme/${kebabCase(component)}`, import.meta.url))
return [
`import template from ${JSON.stringify(templatePath)}`,
...generateVariantDeclarations(variants),
`const result = typeof template === 'function' ? template(${JSON.stringify(options, null, 2)}) : template`,
`const result = typeof template === 'function' ? (template as Function)(${JSON.stringify(options, null, 2)}) : template`,
`const theme = ${json}`,
`export default result as typeof theme`
].join('\n\n')