-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
56 lines (46 loc) · 1.68 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var notify = require('gulp-notify');
var browserSync = require('browser-sync').create();
/*================================================================
# 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);
// keep gulp from hanging on this task
if (typeof this.emit === 'function') this.emit('end')
}
/*================================================================
# TASK
================================================================*/
gulp.task('sass', function() {
return gulp.src('./sass/style.scss')
.pipe(sass({
"opt": {
"sourceComments": false,
"outputStyle": "expanded"
}
})).on('error', handleError)
.pipe(autoprefixer('last 2 versions', '> 1%', 'ie 8'))
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream({ 'once': true }));
});
gulp.task('serve', function() {
browserSync.init({
'server': './',
'open': true
});
gulp.watch('./index.html', { interval: 500 }).on('change', browserSync.reload);
// gulp.watch('./css/style.css', { interval: 500 }).on('change', browserSync.reload);
gulp.watch('./sass/style.scss', ['sass']);
gulp.watch('./js/main.js', { interval: 500 }).on('change', browserSync.reload);
});
gulp.task('default', ['sass', 'serve']);