From e450debc08d30585265077a58250f28e09ca5db8 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 3 Nov 2022 10:54:05 -0400 Subject: [PATCH] feat(kit): add `addServerPlugin` utility (#8635) --- packages/kit/src/nitro.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/kit/src/nitro.ts b/packages/kit/src/nitro.ts index 3222f6be70..d28923280b 100644 --- a/packages/kit/src/nitro.ts +++ b/packages/kit/src/nitro.ts @@ -32,6 +32,15 @@ export function addDevServerHandler (handler: NitroDevEventHandler) { useNuxt().options.devServerHandlers.push(handler) } +/** + * Adds a Nitro plugin + */ +export function addServerPlugin (plugin: string) { + const nuxt = useNuxt() + nuxt.options.nitro.plugins = nuxt.options.nitro.plugins || [] + nuxt.options.nitro.plugins.push(normalize(plugin)) +} + /** * Access to the Nitro instance *