Skip to content

Commit

Permalink
feat: add serve --hmr flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Apr 10, 2024
1 parent 94f894c commit 3e11c21
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions commands/serve.ts
Expand Up @@ -28,6 +28,11 @@ export default class Serve extends BaseCommand {
'{{ binaryName }} serve --watch',
'```',
'',
'You can also start the server with HMR support using the following command.',
'```',
'{{ binaryName }} serve --hmr',
'```',
'',
'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
'You may pass vite CLI args using the --assets-args command line flag.',
'```',
Expand All @@ -41,6 +46,9 @@ export default class Serve extends BaseCommand {

declare devServer: DevServer

@flags.boolean({ description: 'Start the server with HMR support' })
declare hmr?: boolean

@flags.boolean({
description: 'Watch filesystem and restart the HTTP server on file change',
alias: 'w',
Expand Down Expand Up @@ -112,7 +120,14 @@ export default class Serve extends BaseCommand {
return
}

if (this.watch && this.hmr) {
this.logger.error('Cannot use --watch and --hmr flags together. Choose one of them')
this.exitCode = 1
return
}

this.devServer = new assembler.DevServer(this.app.appRoot, {
hmr: this.hmr === true ? true : false,

Check failure on line 130 in commands/serve.ts

View workflow job for this annotation

GitHub Actions / typecheck / typecheck

Object literal may only specify known properties, and 'hmr' does not exist in type 'DevServerOptions'.
clearScreen: this.clear === false ? false : true,
nodeArgs: this.parsed.nodeArgs,
scriptArgs: [],
Expand Down

0 comments on commit 3e11c21

Please sign in to comment.