2022-01-13 11:59:26 +00:00
|
|
|
import { useNuxt, installModule } from '@nuxt/kit'
|
|
|
|
import scriptSetupPlugin from 'unplugin-vue2-script-setup/nuxt'
|
2021-11-29 12:17:29 +00:00
|
|
|
import type { ScriptSetupOptions } from '../types'
|
2021-10-07 08:31:29 +00:00
|
|
|
|
2022-01-13 11:59:26 +00:00
|
|
|
export const setupScriptSetup = async (options: ScriptSetupOptions) => {
|
2021-10-07 08:31:29 +00:00
|
|
|
const nuxt = useNuxt()
|
2021-11-29 12:17:29 +00:00
|
|
|
const config = options === true ? {} : options
|
2021-10-07 08:31:29 +00:00
|
|
|
|
|
|
|
nuxt.hook('prepare:types', ({ references }) => {
|
|
|
|
references.push({
|
|
|
|
types: 'unplugin-vue2-script-setup/types'
|
|
|
|
})
|
|
|
|
})
|
2022-01-13 11:59:26 +00:00
|
|
|
|
|
|
|
await installModule(scriptSetupPlugin, config)
|
2021-10-07 08:31:29 +00:00
|
|
|
}
|