Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass resolved config to rollup:before hook #1160

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/rollup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/types/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface PrerenderGenerateRoute extends PrerenderRoute {

type HookResult = void | Promise<void>;
export interface NitroHooks {
"rollup:before": (nitro: Nitro) => HookResult;
"rollup:before": (nitro: Nitro, config: RollupConfig) => HookResult;
compiled: (nitro: Nitro) => HookResult;
"dev:reload": () => HookResult;
close: () => HookResult;
Expand Down