mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-26 01:40:34 +01:00
feat(module): add support for vue using unplugin (#2416)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
25
src/plugins/app-config.ts
Normal file
25
src/plugins/app-config.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { UnpluginOptions } from 'unplugin'
|
||||
|
||||
import type { NuxtUIOptions } from '../unplugin'
|
||||
|
||||
/**
|
||||
* This plugin injects Nuxt UI configuration into the runtime build so Nuxt UI components can
|
||||
* access it.
|
||||
*/
|
||||
export default function AppConfigPlugin(options: NuxtUIOptions & { theme: NonNullable<NuxtUIOptions['theme']> }, appConfig: Record<string, any>) {
|
||||
return {
|
||||
name: 'nuxt:ui:app-config',
|
||||
enforce: 'pre',
|
||||
resolveId(id) {
|
||||
if (id === '#build/app.config') {
|
||||
return 'virtual:nuxt-ui-app-config'
|
||||
}
|
||||
},
|
||||
loadInclude: id => id === 'virtual:nuxt-ui-app-config',
|
||||
load() {
|
||||
return `
|
||||
export default ${JSON.stringify(appConfig!)}
|
||||
`
|
||||
}
|
||||
} satisfies UnpluginOptions
|
||||
}
|
||||
Reference in New Issue
Block a user