diff --git a/lib/dev.js b/lib/dev.js index 784f7ea..5966743 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -14,7 +14,7 @@ const SERVER_OPTIONS = {} export default function createServer(root = '', conf = {}) { const IS_MPA = Object.keys(conf.pages).length > 1 - const PORT = conf.devServer.port + const PORT = conf.devServer.port || 8080 const USE_HTTPS = conf.devServer.https const DOMAIN = conf.devServer.domain || 'localhost' const WEB_SERVER = USE_HTTPS ? https : http @@ -175,7 +175,7 @@ export default function createServer(root = '', conf = {}) { .listen(PORT) .on('error', err => { console.log(`${PORT}端口被占用~~~`) - conf.devServer.port++ + conf.devServer.port = PORT + 1 createServer(root, conf) }) .on('listening', _ => {