添加 dist 参数,用作 webroot 目录
This commit is contained in:
		
							parent
							
								
									cfd9743f20
								
							
						
					
					
						commit
						c3fc3e2c88
					
				| @ -39,6 +39,7 @@ try { | ||||
|   .option('-H, --host <host>', `Host ip or domain name. Default to ${Config.host}`) | ||||
|   .option('-P, --protocol <protocol>', `Web server protocol http|https|httpall|http2https. Default to ${Config.protocol}`) | ||||
|   .option('-p, --port <port>', `Server port. Default to ${Config.port?Config.port:'80|443'}`) | ||||
|   .option('-d, --dist <dist>', `Distribution folder to serve as webroot. Default to ${Config.dist}`) | ||||
|   .option('--sslType <type>', `SSL provider type. Default to ${Config.sslType}`) | ||||
|   .option('--sslCert <cert>', `SSL certificate file. Default to ${Config.sslCert}`) | ||||
|   .option('--sslKey <key>', `SSL private key file. Default to ${Config.sslKey}`) | ||||
| @ -49,6 +50,7 @@ try { | ||||
|   Config.host=commander.host || Config.host | ||||
|   Config.protocol=commander.protocol || Config.protocol  || 'http' | ||||
|   Config.port=parseInt(commander.port) || parseInt(Config.port) || (Config.protocol==='http'?80:Config.protocol==='https'?443:undefined) // 端口默认为 http:80, https:443, httpall: 80|443
 | ||||
|   Config.dist = commander.dist || Config.dist || 'dist' | ||||
|   Config.sslType = commander.sslType || Config.sslType | ||||
|   Config.sslCert=commander.sslCert || Config.sslCert | ||||
|   Config.sslKey=commander.sslKey || Config.sslKey | ||||
| @ -89,7 +91,7 @@ async function init(){  /*** 设置全局对象 ***/ | ||||
|   server.use(require('compression')()) | ||||
| 
 | ||||
|   /*** 路由 ***/ | ||||
|   server.use(require('express').static(path.join(process.cwd(), 'dist'), {index: 'index.html'})) | ||||
|   server.use(require('express').static(path.join(process.cwd(), wo.Config.dist), {index: 'index.html'})) | ||||
|   // server.use(require('serve-favicon')(path.join(__dirname, 'public', 'favicon.ico')))  // uncomment after placing your favicon in /public
 | ||||
| 
 | ||||
|   let ipv4 = getMyIp() | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user