forked from jojoee/add2calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (47 loc) · 1.63 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var gulp = require('gulp');
var notify = require('gulp-notify');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
/*================================================================
# HELPER
================================================================*/
function handleError(err) {
var msg = 'Error: ' + err.message;
console.error('Error', err.message);
browserSync.notify('Error: ' + err.message);
var args = Array.prototype.slice.call(arguments);
notify.onError({
title: 'Compile Error',
message: '<%= error.message %>'
}).apply(this, args);
if (typeof this.emit === 'function') this.emit('end')
}
/*================================================================
# TASK
================================================================*/
gulp.task('sass', function() {
return gulp.src('./sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
'sourceComments': false,
'outputStyle': 'expanded'
})).on('error', handleError)
.pipe(autoprefixer('last 2 versions', '> 1%', 'ie 8'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./css/'))
.pipe(browserSync.stream({
'once': true
}));
});
gulp.task('serve', function() {
browserSync.init({
'server': './',
'open': true
});
gulp.watch('./sass/*.scss', ['sass']);
gulp.watch('./js/*.js', { interval: 500 }).on('change', browserSync.reload);
gulp.watch('./index.html', { interval: 500 }).on('change', browserSync.reload);
});
gulp.task('default', ['serve']);