mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-22 16:00:39 +01:00
feat(module): add support for vue using unplugin (#2416)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { defu } from 'defu'
|
||||
import { createResolver, defineNuxtModule, addComponentsDir, addImportsDir, addVitePlugin, addPlugin, installModule, hasNuxtModule } from '@nuxt/kit'
|
||||
import { addTemplates } from './templates'
|
||||
import icons from './theme/icons'
|
||||
import { pick } from './runtime/utils'
|
||||
import { defaultOptions, getDefaultUiConfig, resolveColors } from './defaults'
|
||||
|
||||
export type * from './runtime/types'
|
||||
|
||||
@@ -58,37 +57,18 @@ export default defineNuxtModule<ModuleOptions>({
|
||||
},
|
||||
docs: 'https://ui3.nuxt.dev/getting-started/installation'
|
||||
},
|
||||
defaults: {
|
||||
prefix: 'U',
|
||||
fonts: true,
|
||||
colorMode: true,
|
||||
theme: {
|
||||
colors: undefined,
|
||||
transitions: true
|
||||
}
|
||||
},
|
||||
defaults: defaultOptions,
|
||||
async setup(options, nuxt) {
|
||||
const { resolve } = createResolver(import.meta.url)
|
||||
|
||||
options.theme = options.theme || {}
|
||||
options.theme.colors = options.theme.colors?.length ? [...new Set(['primary', ...options.theme.colors])] : ['primary', 'secondary', 'success', 'info', 'warning', 'error']
|
||||
options.theme.colors = resolveColors(options.theme.colors)
|
||||
|
||||
nuxt.options.ui = options
|
||||
|
||||
nuxt.options.alias['#ui'] = resolve('./runtime')
|
||||
|
||||
nuxt.options.appConfig.ui = defu(nuxt.options.appConfig.ui || {}, {
|
||||
colors: pick({
|
||||
primary: 'green',
|
||||
secondary: 'blue',
|
||||
success: 'green',
|
||||
info: 'blue',
|
||||
warning: 'yellow',
|
||||
error: 'red',
|
||||
neutral: 'slate'
|
||||
}, [...(options.theme?.colors || []), 'neutral' as any]),
|
||||
icons
|
||||
})
|
||||
nuxt.options.appConfig.ui = defu(nuxt.options.appConfig.ui || {}, getDefaultUiConfig(options.theme.colors))
|
||||
|
||||
// Isolate root node from portaled components
|
||||
nuxt.options.app.rootAttrs = nuxt.options.app.rootAttrs || {}
|
||||
|
||||
Reference in New Issue
Block a user