Created
January 15, 2015 14:59
-
-
Save misscs/a2d1526a27e7456cb50f to your computer and use it in GitHub Desktop.
Setting up browser sync via Gulp with Harp web server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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