ff-stream-web

git clone git://archive.git.mtrnord.blog/MTRNord/ff-stream-web.git
Log | Files | Refs | README | LICENSE

commit 795b31e8eb672be2422dfc32757c0e96d85a50f7
parent 8d8c92f06e379a21cb907956ee9ee240e9c295b4
Author: Konstantin Tarkus <hello@tarkus.me>
Date:   Wed, 24 Sep 2014 21:05:12 +0400

Add gulp-size and gulp-changed plugins; update browserSync reload logic

Diffstat:
Mgulpfile.js | 19++++++++++---------
Mpackage.json | 1+
2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js @@ -35,7 +35,6 @@ var AUTOPREFIXER_BROWSERS = [ // https://github.com/ai/autoprefi var src = {}; var watch = false; -var reload = browserSync.reload; var pkgs = (function () { var temp = {}; var map = function (source) { @@ -67,33 +66,36 @@ gulp.task('vendor', function () { gulp.task('assets', function () { src.assets = 'src/assets/**'; return gulp.src(src.assets) + .pipe($.changed(DEST)) .pipe(gulp.dest(DEST)) - .pipe($.if(watch, reload({stream: true}))); + .pipe($.size({title: 'assets'})); }); // Images gulp.task('images', function () { src.images = 'src/images/**'; return gulp.src(src.images) + .pipe($.changed(DEST + '/images')) .pipe($.cache($.imagemin({ progressive: true, interlaced: true }))) .pipe(gulp.dest(DEST + '/images')) - .pipe($.if(watch, reload({stream: true}))); + .pipe($.size({title: 'images'})); }); // HTML pages gulp.task('pages', function () { src.pages = 'src/pages/**/*.html'; return gulp.src(src.pages) + .pipe($.changed(DEST)) .pipe($.if(RELEASE, $.htmlmin({ removeComments: true, collapseWhitespace: true, minifyJS: true }))) .pipe(gulp.dest(DEST)) - .pipe($.if(watch, reload({stream: true}))); + .pipe($.size({title: 'pages'})); }); // CSS style sheets @@ -110,7 +112,7 @@ gulp.task('styles', function () { .pipe($.csscomb()) .pipe($.if(RELEASE, $.minifyCss())) .pipe(gulp.dest(DEST + '/css')) - .pipe($.if(watch, reload({stream: true}))); + .pipe($.size({title: 'styles'})); }); // Bundle @@ -126,10 +128,6 @@ gulp.task('bundle', function (cb) { !!argv.verbose && $.util.log('[webpack]', stats.toString({colors: true})); - if (watch) { - reload(config.output.filename); - } - if (!started) { started = true; return cb(); @@ -167,6 +165,9 @@ gulp.task('serve', function (cb) { gulp.watch(src.images, ['images']); gulp.watch(src.pages, ['pages']); gulp.watch(src.styles, ['styles']); + gulp.watch(DEST + '/**/*.*', function (file) { + browserSync.reload(path.relative(__dirname, file.path)); + }); cb(); }); }); diff --git a/package.json b/package.json @@ -27,6 +27,7 @@ "gulp-load-plugins": "^0.6.0", "gulp-minify-css": "^0.3.10", "gulp-plumber": "^0.6.5", + "gulp-size": "^1.1.0", "gulp-uglify": "^1.0.1", "gulp-util": "^3.0.1", "jshint": "^2.5.6",