mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 01:15:58 +00:00
feat(bridge): allow user-defined scriptSetup
options (#2185)
Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
parent
2c4a001b77
commit
ac98373b4c
@ -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()
|
||||
|
@ -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({
|
||||
|
5
packages/bridge/types.d.ts
vendored
5
packages/bridge/types.d.ts
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user