-
-
Save ngekoding/9da15fda0f27a44b3ead0c84d3328c55 to your computer and use it in GitHub Desktop.
Sass & Pug + BrowserSync
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 pug = require('gulp-pug'); | |
var sass = require('gulp-sass'); | |
var browserSync = require('browser-sync').create(); | |
// Compile pug files into HTML | |
gulp.task('pug', function () { | |
return gulp.src('src/pug/*.pug') | |
.pipe(pug()) | |
.pipe(gulp.dest('dist')); | |
}); | |
// Compile sass files into CSS | |
gulp.task('sass', function () { | |
return gulp.src('src/sass/main.sass') | |
.pipe(sass({ | |
includePaths: ['src/sass'], | |
errLogToConsole: true, | |
outputStyle: 'compressed', | |
onError: browserSync.notify | |
})) | |
.pipe(gulp.dest('dist/css')) | |
.pipe(browserSync.stream()); | |
}); | |
// Serve and watch sass/pug files for changes | |
gulp.task('watch', ['pug', 'sass'], function () { | |
browserSync.init({ | |
server: 'dist' | |
}), | |
gulp.watch('src/sass/**/*.sass', ['sass']); | |
gulp.watch('src/pug/*.pug', ['pug']); | |
gulp.watch('dist/*.html').on('change', browserSync.reload); | |
}); | |
gulp.task('default', ['watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment