Skip to content

Commit

Permalink
chore: doc provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Feb 27, 2024
1 parent 51ef82e commit c739008
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions providers/vite_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ export default class ViteProvider {
#shouldRunVite: boolean

constructor(protected app: ApplicationService) {
const env = this.app.getEnvironment()

/**
* We should only run Vite in development and test environments
*/
const env = this.app.getEnvironment()
this.#shouldRunVite = (this.app.inDev || this.app.inTest) && (env === 'web' || env === 'test')
}

Expand All @@ -43,6 +42,9 @@ export default class ViteProvider {
}
}

/**
* Register Vite bindings
*/
register() {
const config = this.app.config.get<ViteOptions>('vite')

Expand All @@ -51,6 +53,10 @@ export default class ViteProvider {
this.app.container.bind(ViteMiddleware, () => new ViteMiddleware(vite))
}

/**
* - Register edge tags
* - Start Vite server when running in development or test
*/
async boot() {
await this.registerEdgePlugin()

Expand All @@ -63,6 +69,9 @@ export default class ViteProvider {
server.use([() => import('../src/middlewares/vite_middleware.js')])
}

/**
* Stop Vite server when running in development or test
*/
async shutdown() {
if (!this.#shouldRunVite) return

Expand Down

0 comments on commit c739008

Please sign in to comment.