fix: vite types (#3352)

* Re-export vite types and added them to zod schema

* Removed casted typed

* Changeset
This commit is contained in:
Juan Martín Seery 2022-05-12 13:55:29 -03:00 committed by GitHub
parent 7cd4b1bc12
commit 8685506174
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Export `ViteUserConfig` type

View file

@ -255,6 +255,10 @@ type ServerConfig = {
port?: number;
};
export interface ViteUserConfig extends vite.UserConfig {
ssr?: vite.SSROptions;
}
/**
* Astro User Config
* Docs: https://docs.astro.build/reference/configuration-reference/
@ -652,7 +656,7 @@ export interface AstroUserConfig {
* }
* ```
*/
vite?: vite.UserConfig & { ssr?: vite.SSROptions };
vite?: ViteUserConfig;
experimental?: {
/**

View file

@ -120,7 +120,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
const ssr = isBuildingToSSR(astroConfig);
const out = ssr ? opts.buildConfig.server : astroConfig.outDir;
const viteBuildConfig = {
const viteBuildConfig: ViteConfigWithSSR = {
logLevel: 'error',
mode: 'production',
css: viteConfig.css,
@ -165,7 +165,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
base: astroConfig.base,
ssr: viteConfig.ssr,
resolve: viteConfig.resolve,
} as ViteConfigWithSSR;
};
await runHookBuildSetup({
config: astroConfig,

View file

@ -1,4 +1,4 @@
import type { AstroConfig, AstroUserConfig, CLIFlags } from '../@types/astro';
import type { AstroConfig, AstroUserConfig, CLIFlags, ViteUserConfig } from '../@types/astro';
import type { Arguments as Flags } from 'yargs-parser';
import type * as Postcss from 'postcss';
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
@ -182,7 +182,9 @@ export const AstroConfigSchema = z.object({
.default([]),
})
.default({}),
vite: z.any().optional().default({}),
vite: z
.custom<ViteUserConfig>((data) => data instanceof Object && !Array.isArray(data))
.default({}),
experimental: z
.object({
ssr: z.boolean().optional().default(false),