diff --git a/packages/bridge/src/module.ts b/packages/bridge/src/module.ts index 4943b7ec19..f9cfb8bf8a 100644 --- a/packages/bridge/src/module.ts +++ b/packages/bridge/src/module.ts @@ -1,6 +1,6 @@ import { createRequire } from 'module' import { defineNuxtModule, installModule, checkNuxtCompatibilityIssues } from '@nuxt/kit' -import type { BridgeConfig } from '../types' +import type { BridgeConfig, ScriptSetupOptions } from '../types' import { setupNitroBridge } from './nitro' import { setupAppBridge } from './app' import { setupCAPIBridge } from './capi' @@ -45,7 +45,7 @@ export default defineNuxtModule({ await setupCAPIBridge(opts.capi) } if (opts.scriptSetup) { - await setupScriptSetup() + await setupScriptSetup(opts.scriptSetup as ScriptSetupOptions) } if (opts.autoImports) { await setupAutoImports() diff --git a/packages/bridge/src/setup.ts b/packages/bridge/src/setup.ts index 351e0cd1e3..4c8167d876 100644 --- a/packages/bridge/src/setup.ts +++ b/packages/bridge/src/setup.ts @@ -1,11 +1,13 @@ import { addVitePlugin, addWebpackPlugin, useNuxt } from '@nuxt/kit' import scriptSetupPlugin from 'unplugin-vue2-script-setup' +import type { ScriptSetupOptions } from '../types' -export const setupScriptSetup = () => { +export const setupScriptSetup = (options: ScriptSetupOptions) => { const nuxt = useNuxt() + const config = options === true ? {} : options - addVitePlugin(scriptSetupPlugin.vite()) - addWebpackPlugin(scriptSetupPlugin.webpack()) + addVitePlugin(scriptSetupPlugin.vite(config)) + addWebpackPlugin(scriptSetupPlugin.webpack(config)) nuxt.hook('prepare:types', ({ references }) => { references.push({ diff --git a/packages/bridge/types.d.ts b/packages/bridge/types.d.ts index 18e1b2b442..ea9e4ac766 100644 --- a/packages/bridge/types.d.ts +++ b/packages/bridge/types.d.ts @@ -1,13 +1,16 @@ import type {} from '@nuxt/nitro' import type { NuxtConfig as _NuxtConfig } from '@nuxt/schema' import type { MetaInfo } from 'vue-meta' +import type { PluginOptions as ScriptSetupPluginOptions } from 'unplugin-vue2-script-setup/dist' + +export type ScriptSetupOptions = ScriptSetupPluginOptions export interface BridgeConfig { nitro: boolean vite: boolean app: boolean | {} capi: boolean | {} - scriptSetup: boolean + scriptSetup: boolean | ScriptSetupOptions autoImports: boolean transpile: boolean constraints: boolean