fix: vite types (#3352)
* Re-export vite types and added them to zod schema * Removed casted typed * Changeset
This commit is contained in:
parent
7cd4b1bc12
commit
8685506174
4 changed files with 16 additions and 5 deletions
5
.changeset/quick-gorillas-kick.md
Normal file
5
.changeset/quick-gorillas-kick.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Export `ViteUserConfig` type
|
|
@ -255,6 +255,10 @@ type ServerConfig = {
|
||||||
port?: number;
|
port?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface ViteUserConfig extends vite.UserConfig {
|
||||||
|
ssr?: vite.SSROptions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Astro User Config
|
* Astro User Config
|
||||||
* Docs: https://docs.astro.build/reference/configuration-reference/
|
* Docs: https://docs.astro.build/reference/configuration-reference/
|
||||||
|
@ -652,7 +656,7 @@ export interface AstroUserConfig {
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
vite?: vite.UserConfig & { ssr?: vite.SSROptions };
|
vite?: ViteUserConfig;
|
||||||
|
|
||||||
experimental?: {
|
experimental?: {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -120,7 +120,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
const ssr = isBuildingToSSR(astroConfig);
|
const ssr = isBuildingToSSR(astroConfig);
|
||||||
const out = ssr ? opts.buildConfig.server : astroConfig.outDir;
|
const out = ssr ? opts.buildConfig.server : astroConfig.outDir;
|
||||||
|
|
||||||
const viteBuildConfig = {
|
const viteBuildConfig: ViteConfigWithSSR = {
|
||||||
logLevel: 'error',
|
logLevel: 'error',
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
css: viteConfig.css,
|
css: viteConfig.css,
|
||||||
|
@ -165,7 +165,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
base: astroConfig.base,
|
base: astroConfig.base,
|
||||||
ssr: viteConfig.ssr,
|
ssr: viteConfig.ssr,
|
||||||
resolve: viteConfig.resolve,
|
resolve: viteConfig.resolve,
|
||||||
} as ViteConfigWithSSR;
|
};
|
||||||
|
|
||||||
await runHookBuildSetup({
|
await runHookBuildSetup({
|
||||||
config: astroConfig,
|
config: astroConfig,
|
||||||
|
|
|
@ -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 { Arguments as Flags } from 'yargs-parser';
|
||||||
import type * as Postcss from 'postcss';
|
import type * as Postcss from 'postcss';
|
||||||
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
|
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
|
||||||
|
@ -182,7 +182,9 @@ export const AstroConfigSchema = z.object({
|
||||||
.default([]),
|
.default([]),
|
||||||
})
|
})
|
||||||
.default({}),
|
.default({}),
|
||||||
vite: z.any().optional().default({}),
|
vite: z
|
||||||
|
.custom<ViteUserConfig>((data) => data instanceof Object && !Array.isArray(data))
|
||||||
|
.default({}),
|
||||||
experimental: z
|
experimental: z
|
||||||
.object({
|
.object({
|
||||||
ssr: z.boolean().optional().default(false),
|
ssr: z.boolean().optional().default(false),
|
||||||
|
|
Loading…
Reference in a new issue