From 3199e11d6086e4769237901cf22ec182abfbbd8b Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 17 Apr 2023 14:23:50 +0100 Subject: [PATCH] feat: pass resolved config to `rollup:before` hook --- src/build.ts | 2 +- src/rollup/config.ts | 2 +- src/types/nitro.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/build.ts b/src/build.ts index 9d476e178b..2d40a2e023 100644 --- a/src/build.ts +++ b/src/build.ts @@ -58,7 +58,7 @@ export async function copyPublicAssets(nitro: Nitro) { export async function build(nitro: Nitro) { const rollupConfig = getRollupConfig(nitro); - await nitro.hooks.callHook("rollup:before", nitro); + await nitro.hooks.callHook("rollup:before", nitro, rollupConfig); return nitro.options.dev ? _watch(nitro, rollupConfig) : _build(nitro, rollupConfig); diff --git a/src/rollup/config.ts b/src/rollup/config.ts index 9ec15d6563..673161ee80 100644 --- a/src/rollup/config.ts +++ b/src/rollup/config.ts @@ -38,7 +38,7 @@ import { appConfig } from "./plugins/app-config"; export type RollupConfig = InputOptions & { output: OutputOptions }; -export const getRollupConfig = (nitro: Nitro) => { +export const getRollupConfig = (nitro: Nitro): RollupConfig => { const extensions: string[] = [".ts", ".mjs", ".js", ".json", ".node"]; const nodePreset = nitro.options.node === false ? unenv.nodeless : unenv.node; diff --git a/src/types/nitro.ts b/src/types/nitro.ts index 6007bed682..1344f6a4fa 100644 --- a/src/types/nitro.ts +++ b/src/types/nitro.ts @@ -53,7 +53,7 @@ export interface PrerenderGenerateRoute extends PrerenderRoute { type HookResult = void | Promise; export interface NitroHooks { - "rollup:before": (nitro: Nitro) => HookResult; + "rollup:before": (nitro: Nitro, config: RollupConfig) => HookResult; compiled: (nitro: Nitro) => HookResult; "dev:reload": () => HookResult; close: () => HookResult;