-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
33 lines (29 loc) · 1.13 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var autoprefixer= require('gulp-autoprefixer');
// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {
browserSync.init({
notify: false,
server: "./"
});
gulp.watch("scss/style.scss", ['sass']);
gulp.watch("*.html").on('change', browserSync.reload);
gulp.watch("js/*.js").on('change', browserSync.reload);
});
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src("scss/style.scss")
.pipe(sass().on('error', function(err) { //Compile and compress sass
console.error(err.message);
browserSync.notify(err.message, 3000); // Display error
this.emit('end'); // Prevent gulp from catching the error and exiting the watch process
}))
.pipe(autoprefixer({
browsers: ['Safari >= 6.1', 'IE >= 10', 'Firefox >= 28'],
cascade: false}))
.pipe(gulp.dest("./css"))
.pipe(browserSync.stream());
});
gulp.task('default', ['serve']);