Skip to content

Commit

Permalink
refactor: register vite middleware in boot method
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Feb 27, 2024
1 parent cd12fbb commit 8e65616
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions providers/vite_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,12 @@ export default class ViteProvider {
}
}

async register() {
register() {
const config = this.app.config.get<ViteOptions>('vite')

const vite = new Vite(this.app.inDev, config)
this.app.container.bind('vite', () => vite)
this.app.container.bind(ViteMiddleware, () => new ViteMiddleware(vite))

if (this.app.inDev) {
const server = await this.app.container.make('server')
server.use([() => import('../src/middlewares/vite_middleware.js')])
}
}

async boot() {
Expand All @@ -53,7 +48,10 @@ export default class ViteProvider {
if (!this.app.inDev) return

const vite = await this.app.container.make('vite')
const server = await this.app.container.make('server')

await vite.createDevServer()
server.use([() => import('../src/middlewares/vite_middleware.js')])
}

async shutdown() {
Expand Down

0 comments on commit 8e65616

Please sign in to comment.