@@ -102,6 +102,16 @@ function cleanOptions<Options extends GlobalCLIOptions>(
102102 return ret
103103}
104104
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+
105115cli
106116 . option ( '-c, --config <file>' , `[string] use specified config file` )
107117 . option ( '--base <path>' , `[string] public base path (default: /)` )
116126 . command ( '[root]' , 'start dev server' ) // default command
117127 . alias ( 'serve' ) // the command is called 'serve' in Vite's API
118128 . 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 ] } )
120130 . option ( '--port <port>' , `[number] specify port` )
121131 . option ( '--https' , `[boolean] use TLS + HTTP/2` )
122132 . option ( '--open [path]' , `[boolean | string] open browser on startup` )
306316// preview
307317cli
308318 . command ( 'preview [root]' , 'locally preview production build' )
309- . option ( '--host [host]' , `[string] specify hostname` )
319+ . option ( '--host [host]' , `[string] specify hostname` , { type : [ convertHost ] } )
310320 . option ( '--port <port>' , `[number] specify port` )
311321 . option ( '--strictPort' , `[boolean] exit if specified port is already in use` )
312322 . option ( '--https' , `[boolean] use TLS + HTTP/2` )
0 commit comments