@@ -102,6 +102,16 @@ function cleanOptions<Options extends GlobalCLIOptions>(
102
102
return ret
103
103
}
104
104
105
+ /**
106
+ * host may be a number (like 0), should convert to string
107
+ */
108
+ const convertHost = ( v : any ) => {
109
+ if ( typeof v === 'number' ) {
110
+ return String ( v )
111
+ }
112
+ return v
113
+ }
114
+
105
115
cli
106
116
. option ( '-c, --config <file>' , `[string] use specified config file` )
107
117
. option ( '--base <path>' , `[string] public base path (default: /)` )
116
126
. command ( '[root]' , 'start dev server' ) // default command
117
127
. alias ( 'serve' ) // the command is called 'serve' in Vite's API
118
128
. alias ( 'dev' ) // alias to align with the script name
119
- . option ( '--host [host]' , `[string] specify hostname` )
129
+ . option ( '--host [host]' , `[string] specify hostname` , { type : [ convertHost ] } )
120
130
. option ( '--port <port>' , `[number] specify port` )
121
131
. option ( '--https' , `[boolean] use TLS + HTTP/2` )
122
132
. option ( '--open [path]' , `[boolean | string] open browser on startup` )
306
316
// preview
307
317
cli
308
318
. command ( 'preview [root]' , 'locally preview production build' )
309
- . option ( '--host [host]' , `[string] specify hostname` )
319
+ . option ( '--host [host]' , `[string] specify hostname` , { type : [ convertHost ] } )
310
320
. option ( '--port <port>' , `[number] specify port` )
311
321
. option ( '--strictPort' , `[boolean] exit if specified port is already in use` )
312
322
. option ( '--https' , `[boolean] use TLS + HTTP/2` )
0 commit comments