Nuxt/packages/bridge/src/setup.ts
Yasser Lahbibi ac98373b4c
feat(bridge): allow user-defined scriptSetup options (#2185)
Co-authored-by: pooya parsa <pyapar@gmail.com>
2021-11-29 13:17:29 +01:00

18 lines
560 B
TypeScript

import { addVitePlugin, addWebpackPlugin, useNuxt } from '@nuxt/kit'
import scriptSetupPlugin from 'unplugin-vue2-script-setup'
import type { ScriptSetupOptions } from '../types'
export const setupScriptSetup = (options: ScriptSetupOptions) => {
const nuxt = useNuxt()
const config = options === true ? {} : options
addVitePlugin(scriptSetupPlugin.vite(config))
addWebpackPlugin(scriptSetupPlugin.webpack(config))
nuxt.hook('prepare:types', ({ references }) => {
references.push({
types: 'unplugin-vue2-script-setup/types'
})
})
}