Skip to content

Commit

Permalink
fix(hmr): fix hmr when using h2 and use merge config (#110)
Browse files Browse the repository at this point in the history
* fix hmr when using h2 and use merge config

* flip order
  • Loading branch information
benatshippabo authored Jun 4, 2023
1 parent 4e04c63 commit 568e178
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/fastify-vite/mode/development.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const middie = require('@fastify/middie')
const { mergeConfig, defineConfig } = require('vite')
const { join, resolve, read } = require('../ioutils')

async function setup (config) {
Expand All @@ -7,15 +8,20 @@ async function setup (config) {
await this.scope.register(middie)

// Create and enable Vite's Dev Server middleware
const devServerOptions = {
configFile: false,
...config.vite,
server: {
middlewareMode: true,
...config.vite.server
},
appType: 'custom'
}
const devServerOptions = mergeConfig(
defineConfig({
configFile: false,
server: {
middlewareMode: true,
hmr: {
server: this.scope.server
}
},
appType: 'custom'
}),
config.vite
)

const { createServer } = require('vite')
this.devServer = await createServer(devServerOptions)
this.scope.use(this.devServer.middlewares)
Expand Down

0 comments on commit 568e178

Please sign in to comment.