Skip to content

Instantly share code, notes, and snippets.

@misscs
Created January 15, 2015 14:59
Show Gist options
  • Save misscs/a2d1526a27e7456cb50f to your computer and use it in GitHub Desktop.
Save misscs/a2d1526a27e7456cb50f to your computer and use it in GitHub Desktop.
Setting up browser sync via Gulp with Harp web server
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var harp = require('harp');
var scsslint = require('gulp-scss-lint');
var paths = {
templates: '**/*.{jade,md}',
css: 'assets/stylesheets/*.css',
sass: ['assets/stylesheets/**/*.scss', 'assets/stylesheets/*.scss'],
images: 'assets/stylesheets/img/**/*',
js: 'assets/js/**/*.js',
fonts: 'aseets/fonts/**/*',
};
/**
* Serve the Harp Site from the src directory
*/
gulp.task('serve', function () {
harp.server(__dirname, {
port: 9000
}, function () {
browserSync({
proxy: "localhost:9000",
open: false,
ghostMode: {
clicks: true,
forms: false,
scroll: true
},
logLevel: "debug",
notify: false
});
/**
* Watch for scss changes, tell BrowserSync to refresh css
*/
gulp.watch(paths.sass, function () {
reload(paths.css, {stream: true});
});
})
});
/**
* Lint files
*/
gulp.task('lint', function() {
gulp.src(paths.sass)
.pipe(scsslint());
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the harp site, launch BrowserSync & watch files.
*/
gulp.task('default', ['serve']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment