hrap + browsersync

https://github.com/superhighfives/harp-gulp-browsersync-boilerplate

https://gist.github.com/geelen/a5fcb013de67f680cb8d

gulp配置

var gulp        = require('gulp');
var browserSync = require('browser-sync');
var reload      = browserSync.reload;
var harp        = require('harp');

/**
* Serve the Harp Site from the src directory
*/
gulp.task('serve', function () {
  harp.server(__dirname + '/app', {
    port: 9000
  }, function () {
    browserSync({
      proxy: "localhost:9000",
      open: false,
      /* Hide the notification. It gets annoying */
      notify: {
        styles: ['opacity: 0', 'position: absolute']
      }
    });
    /**
     * Watch for scss changes, tell BrowserSync to refresh main.css
     */
    gulp.watch("app/**/*.scss", function () {
      reload("main.css", {stream: true});
    });
    /**
     * Watch for all other changes, reload the whole page
     */
    gulp.watch(["./*.js","./app/*.ejs", "./app/js/*.js",'./app/partials/*.ejs','./app/*.json'], function () {
      reload();
    });
  })
});

/**
* Default task, running just `gulp` will compile the sass,
* compile the harp site, launch BrowserSync & watch files.
*/
gulp.task('default', ['serve']);

posted @ 2016-04-20 10:41  lihuazhidao  阅读(177)  评论(0)    收藏  举报