javascript - Very slow BrowserSync server startup with Gulp -


[edit: solved!]

see answer below.

[>>original question follows<<]

i'm using browsersync in server mode (using built-in static server) gulpjs on local project, , seems working correctly except browsersync server slow startup. browsersync seems initialize right away when run gulp, takes 4 5 minutes (and more) server start , return access urls. during period, continues run , browsersync responds reload() calls , such, access not available via usual urls (in case, localhost:3000 , localhost:3001). once access urls returned, server has seemingly started , browsersync's page refreshes work fine , speedy.

i have tried several different configurations of gulpfile.js, trying different ways initialize browsersync, different approaches calling stream() , reload() methods (including trying browsersync's basic gulp/sass "recipe"), , different port numbers, configurations had same problem. tried disabling firewall , av software (avast), nothing.

i'm running windows 8.1, if that's relevant. browsersync freshly installed locally project via npm, , fresh local installs other directories have same problem. npm, ruby, gulp, , modules seem up-to-date. it's worth, of other experience ruby, gulp, , node.js have been smooth , problem-free.

i can't find other posts mentioning problem , beginning think normal behavior. normal, and, if not, have ideas of things try? delay not end of world since browsersync server start (eventually), it's still kink in workflow i'd rather fix deal with.

finally, here gulpfile.js: /* file: gulpfile.js */

var gulp  = require('gulp'),     gutil = require('gulp-util');     jshint = require('gulp-jshint');     sass   = require('gulp-sass');     concat = require('gulp-concat');     uglify = require('gulp-uglify');     sourcemaps = require('gulp-sourcemaps');     imagemin = require('gulp-imagemin');     browsersync = require('browser-sync').create();  gulp.task('default', ['watch'], browsersync.reload);  // jshint gulp.task('jshint', function() {   return gulp.src('src/js/**/*.js')     .pipe(jshint())     .pipe(jshint.reporter('jshint-stylish')); });  // build js gulp.task('build-js', function() {   return gulp.src('src/js/**/*.js')     .pipe(sourcemaps.init())       .pipe(concat('main.js'))       //only uglify if gulp ran '--type production'       .pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())      .pipe(sourcemaps.write())     .pipe(gulp.dest('public/www/js/core')); });  // build css gulp.task('build-css', function() {     return gulp.src('src/sass/**/*.{sass,scss}')         .pipe(sourcemaps.init())             .pipe(sass()).on('error', handleerror)         .pipe(sourcemaps.write()) // add map modified source.         .pipe(gulp.dest('public/www/css/core'))         .pipe(browsersync.stream({match: '**/*.css'})); });  // imagemin gulp.task('imagemin', function () {     return gulp.src('src/img/*')         .pipe(imagemin({             progressive: true,             svgoplugins: [{removeviewbox: false}]         }))         .pipe(gulp.dest('public/www/img')); });  // handle errors function handleerror(err) {   console.log(err.tostring());   this.emit('end'); }  // watch function gulp.task('watch', function() {     browsersync.init({       server: "./public/www",       //port: 3002     });      gulp.watch('src/js/**/*.js', ['jshint']);     gulp.watch('src/sass/**/*.{sass,scss}', ['build-css']);     gulp.watch('src/js/**/*.js', ['build-js']);     gulp.watch('src/img/*', ['imagemin']);     gulp.watch("public/www/css/**/*.css").on('change', browsersync.reload); }) 

the browsersync twitter account suggested set "online" option true, and...it seems have worked!

i set in browsersync's init so:

browsersync.init({   server: "./public/www",   online: true }); 

...and delay gone!

going browsersync docs ( http://www.browsersync.io/docs/options/#option-online ), seems setting online option true skips online check. so, guess check somehow causing delay? seems odd me, it's working better now.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -