Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(kit): add addServerPlugin utility #8635

Merged
merged 3 commits into from
Nov 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/kit/src/nitro.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack'
import { normalize } from 'pathe'
import { useNuxt } from './context'

/**
Expand Down Expand Up @@ -30,6 +31,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 || []
pi0 marked this conversation as resolved.
Show resolved Hide resolved
nuxt.options.nitro.plugins.push(normalize(plugin))
}

/**
* Access to the Nitro instance
*
Expand Down