mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Reverted config hook changes
This commit is contained in:
parent
c2f4dd44e3
commit
56cb78bd40
3 changed files with 19 additions and 17 deletions
|
@ -678,12 +678,12 @@ export interface AstroIntegration {
|
|||
// injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void;
|
||||
}) => void;
|
||||
'astro:config:done'?: (options: { config: AstroConfig; setAdapter: (adapter: AstroAdapter) => void }) => void | Promise<void>;
|
||||
'astro:server:setup'?: (options: { config: Readonly<AstroConfig>; server: vite.ViteDevServer }) => void | Promise<void>;
|
||||
'astro:server:start'?: (options: { config: Readonly<AstroConfig>; address: AddressInfo }) => void | Promise<void>;
|
||||
'astro:server:done'?: (options: { config: Readonly<AstroConfig> }) => void | Promise<void>;
|
||||
'astro:build:start'?: (options: { config: Readonly<AstroConfig>; buildConfig: BuildConfig }) => void | Promise<void>;
|
||||
'astro:build:setup'?: (options: { config: Readonly<AstroConfig>; vite: ViteConfigWithSSR; target: 'client' | 'server' }) => void;
|
||||
'astro:build:done'?: (options: { config: Readonly<AstroConfig>; pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
|
||||
'astro:server:setup'?: (options: { server: vite.ViteDevServer }) => void | Promise<void>;
|
||||
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
|
||||
'astro:server:done'?: () => void | Promise<void>;
|
||||
'astro:build:start'?: (options: { buildConfig: BuildConfig }) => void | Promise<void>;
|
||||
'astro:build:setup'?: (options: { vite: ViteConfigWithSSR; target: 'client' | 'server' }) => void;
|
||||
'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ export async function runHookConfigDone({ config }: { config: AstroConfig }) {
|
|||
export async function runHookServerSetup({ config, server }: { config: AstroConfig; server: ViteDevServer }) {
|
||||
for (const integration of config.integrations) {
|
||||
if (integration.hooks['astro:server:setup']) {
|
||||
await integration.hooks['astro:server:setup']({ config, server });
|
||||
await integration.hooks['astro:server:setup']({ server });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ export async function runHookServerSetup({ config, server }: { config: AstroConf
|
|||
export async function runHookServerStart({ config, address }: { config: AstroConfig; address: AddressInfo }) {
|
||||
for (const integration of config.integrations) {
|
||||
if (integration.hooks['astro:server:start']) {
|
||||
await integration.hooks['astro:server:start']({ config, address });
|
||||
await integration.hooks['astro:server:start']({ address });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ export async function runHookServerStart({ config, address }: { config: AstroCon
|
|||
export async function runHookServerDone({ config }: { config: AstroConfig }) {
|
||||
for (const integration of config.integrations) {
|
||||
if (integration.hooks['astro:server:done']) {
|
||||
await integration.hooks['astro:server:done']({ config });
|
||||
await integration.hooks['astro:server:done']();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ export async function runHookServerDone({ config }: { config: AstroConfig }) {
|
|||
export async function runHookBuildStart({ config, buildConfig }: { config: AstroConfig; buildConfig: BuildConfig }) {
|
||||
for (const integration of config.integrations) {
|
||||
if (integration.hooks['astro:build:start']) {
|
||||
await integration.hooks['astro:build:start']({ config, buildConfig });
|
||||
await integration.hooks['astro:build:start']({ buildConfig });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ export async function runHookBuildStart({ config, buildConfig }: { config: Astro
|
|||
export async function runHookBuildSetup({ config, vite, target }: { config: AstroConfig; vite: ViteConfigWithSSR; target: 'server' | 'client' }) {
|
||||
for (const integration of config.integrations) {
|
||||
if (integration.hooks['astro:build:setup']) {
|
||||
await integration.hooks['astro:build:setup']({ config, vite, target });
|
||||
await integration.hooks['astro:build:setup']({ vite, target });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ export async function runHookBuildSetup({ config, vite, target }: { config: Astr
|
|||
export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) {
|
||||
for (const integration of config.integrations) {
|
||||
if (integration.hooks['astro:build:done']) {
|
||||
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes, config });
|
||||
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { AstroAdapter, AstroIntegration } from 'astro';
|
||||
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
|
||||
import type { PathLike } from 'fs';
|
||||
import fs from 'fs/promises';
|
||||
import esbuild from 'esbuild';
|
||||
|
@ -17,6 +17,7 @@ export function getAdapter(): AstroAdapter {
|
|||
}
|
||||
|
||||
export default function vercel(): AstroIntegration {
|
||||
let _config: AstroConfig;
|
||||
return {
|
||||
name: '@astrojs/vercel',
|
||||
hooks: {
|
||||
|
@ -24,13 +25,14 @@ export default function vercel(): AstroIntegration {
|
|||
config.dist = new URL('./.output/', config.projectRoot);
|
||||
config.buildOptions.pageUrlFormat = 'directory';
|
||||
},
|
||||
'astro:config:done': ({ setAdapter }) => {
|
||||
'astro:config:done': ({ setAdapter, config }) => {
|
||||
setAdapter(getAdapter());
|
||||
_config = config;
|
||||
},
|
||||
'astro:build:start': async ({ buildConfig, config }) => {
|
||||
'astro:build:start': async ({ buildConfig }) => {
|
||||
buildConfig.serverEntry = `${ENTRYFILE}.mjs`;
|
||||
buildConfig.client = new URL('./static/', config.dist);
|
||||
buildConfig.server = new URL('./server/pages/', config.dist);
|
||||
buildConfig.client = new URL('./static/', _config.dist);
|
||||
buildConfig.server = new URL('./server/pages/', _config.dist);
|
||||
},
|
||||
'astro:build:done': async ({ dir, routes }) => {
|
||||
const pagesDir = new URL('./server/pages/', dir);
|
||||
|
|
Loading…
Reference in a new issue