mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
chore: simplify theme imports in dev (#3851)
This commit is contained in:
@@ -10,7 +10,8 @@ export default defineBuildConfig({
|
||||
replace: {
|
||||
delimiters: ['', ''],
|
||||
values: {
|
||||
'process.argv.at(-1) === \'--uiDev\'': 'false'
|
||||
// Used in development to import directly from theme
|
||||
'const isUiDev = true': 'const isUiDev = false'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -96,12 +96,12 @@
|
||||
"scripts": {
|
||||
"build": "nuxt-module-build build",
|
||||
"prepack": "pnpm build",
|
||||
"dev": "nuxi dev playground --uiDev",
|
||||
"dev": "nuxi dev playground",
|
||||
"dev:build": "nuxi build playground",
|
||||
"dev:vue": "vite playground-vue -- --uiDev",
|
||||
"dev:vue": "vite playground-vue",
|
||||
"dev:vue:build": "vite build playground-vue",
|
||||
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground && nuxi prepare docs && vite build playground-vue",
|
||||
"docs": "nuxi dev docs --uiDev",
|
||||
"docs": "nuxi dev docs",
|
||||
"docs:build": "nuxi build docs",
|
||||
"docs:prepare": "nuxt-component-meta docs",
|
||||
"lint": "eslint .",
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user