From 0c729598bb09fc2427bc39277aa14ba07ebc1d3b Mon Sep 17 00:00:00 2001 From: progrape Date: Mon, 9 Nov 2015 10:47:17 +0800 Subject: [PATCH] allow custom server port & optimize default task --- gulpfile.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 946b1df..fcb7216 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -54,17 +54,18 @@ gulp.task('watch', function () { }); gulp.task('server', function () { + yargs.p = yargs.p || 8080; browserSync.init({ server: { baseDir: "./dist" }, ui: { - port: 8081, + port: yargs.p + 1, weinre: { - port: 9090 + port: yargs.p + 2 } }, - port: 8080, + port: yargs.p, startPath: '/example' }); }); @@ -74,14 +75,12 @@ gulp.task('server', function () { // -w: 实时监听 // -s: 启动服务器 // -p: 服务器启动端口,默认8080 -gulp.task('default', function () { +gulp.task('default', ['release'], function () { if (yargs.s) { gulp.start('server'); } + if (yargs.w) { - gulp.start('release'); gulp.start('watch'); - } else { - gulp.start('release'); } }); \ No newline at end of file