From 5a3acbddd1958c02b8abefcac829c9bbfa8aecc4 Mon Sep 17 00:00:00 2001 From: zhaojq Date: Fri, 19 Feb 2016 13:25:23 +0800 Subject: [PATCH] update gulpfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 统一命名: build:example:less -> build:example:style 2. 调整 watch,不再任何改动都重新运行所有任务(LESS 的改动可以直接 inject,不会再 reload 页面) --- gulpfile.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 772de63..012dbb2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -35,12 +35,12 @@ gulp.task('build:style', function (){ .pipe(header(banner, { pkg : pkg } )) .pipe(sourcemaps.write()) .pipe(gulp.dest(dist)) + .pipe(browserSync.reload({stream: true})) .pipe(nano()) .pipe(rename(function (path) { path.basename += '.min'; })) - .pipe(gulp.dest(dist)) - .pipe(browserSync.reload({stream: true})); + .pipe(gulp.dest(dist)); }); gulp.task('build:example:assets', function (){ @@ -49,7 +49,7 @@ gulp.task('build:example:assets', function (){ .pipe(browserSync.reload({stream: true})); }); -gulp.task('build:example:less', function (){ +gulp.task('build:example:style', function (){ gulp.src('src/example/example.less', option) .pipe(less().on('error', function (e){ console.error(e.message); @@ -78,14 +78,15 @@ gulp.task('build:example:html', function (){ .pipe(browserSync.reload({stream: true})); }); -gulp.task('build:example', ['build:example:assets', 'build:example:less', 'build:example:html']); +gulp.task('build:example', ['build:example:assets', 'build:example:style', 'build:example:html']); gulp.task('release', ['build:style', 'build:example']); gulp.task('watch', ['release'], function () { - gulp.watch('src/**/*.*', ['release'], function (){ - browserSync.reload(); - }); + gulp.watch('src/style/**/*', ['build:style']); + gulp.watch('src/example/example.less', ['build:example:style']); + gulp.watch('src/example/**/*.?(png|jpg|gif|js)', ['build:example:assets']); + gulp.watch('src/**/*.html', ['build:example:html']); }); gulp.task('server', function () {