diff --git a/server.js b/server.js index 4e27a36..46b369e 100644 --- a/server.js +++ b/server.js @@ -39,6 +39,7 @@ try { .option('-H, --host ', `Host ip or domain name. Default to ${Config.host}`) .option('-P, --protocol ', `Web server protocol http|https|httpall|http2https. Default to ${Config.protocol}`) .option('-p, --port ', `Server port. Default to ${Config.port?Config.port:'80|443'}`) + .option('-d, --dist ', `Distribution folder to serve as webroot. Default to ${Config.dist}`) .option('--sslType ', `SSL provider type. Default to ${Config.sslType}`) .option('--sslCert ', `SSL certificate file. Default to ${Config.sslCert}`) .option('--sslKey ', `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()