fix: Improve Vite config merging (#1768)

#1755
This commit is contained in:
Drew Powers 2021-11-08 14:43:10 -07:00 committed by GitHub
parent fbae2bc52f
commit fd0e9ce605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 14 deletions

View file

@ -55,14 +55,16 @@ class AstroBuilder {
const { logging, origin } = this; const { logging, origin } = this;
const timer: Record<string, number> = { viteStart: performance.now() }; const timer: Record<string, number> = { viteStart: performance.now() };
const viteConfig = await createVite( const viteConfig = await createVite(
{ vite.mergeConfig(
mode: this.mode, {
server: { mode: this.mode,
hmr: { overlay: false }, server: {
middlewareMode: 'ssr', hmr: { overlay: false },
middlewareMode: 'ssr',
},
}, },
...(this.config.vite || {}), this.config.vite || {}
}, ),
{ astroConfig: this.config, logging } { astroConfig: this.config, logging }
); );
const viteServer = await vite.createServer(viteConfig); const viteServer = await vite.createServer(viteConfig);

View file

@ -222,14 +222,16 @@ export class AstroDevServer {
private async createViteServer() { private async createViteServer() {
const viteConfig = await createVite( const viteConfig = await createVite(
{ vite.mergeConfig(
mode: 'development', {
server: { mode: 'development',
middlewareMode: 'ssr', server: {
host: this.hostname, middlewareMode: 'ssr',
host: this.hostname,
},
}, },
...(this.config.vite || {}), this.config.vite || {}
}, ),
{ astroConfig: this.config, logging: this.logging, devServer: this } { astroConfig: this.config, logging: this.logging, devServer: this }
); );
const viteServer = await vite.createServer(viteConfig); const viteServer = await vite.createServer(viteConfig);