-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (53 loc) · 1.54 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
58
59
60
61
62
63
64
65
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var jade = require('gulp-jade');
var reload = browserSync.reload;
/**
* Compile jade files into HTML
*/
gulp.task('templates', function() {
var YOUR_LOCALS = {};
return gulp.src('./src/*.jade')
.pipe(jade({
locals: YOUR_LOCALS
}))
.on('error', swallowError)
.pipe(gulp.dest('./dist/'));
});
/**
* Important!!
* Separate task for the reaction to `.jade` files
*/
gulp.task('jade-watch', ['templates'], reload);
/**
* Sass task for live injecting into all browsers
*/
gulp.task('sass', function () {
return gulp.src('./src/scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('./dist'))
.on('error', swallowError)
.pipe(reload({stream: true}));
});
gulp.task('images', function() {
return gulp.src('./src/img/**/*')
.pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
.pipe(gulp.dest('./dist'))
.on('error', swallowError)
.pipe(reload({stream:true}));
});
/**
* Serve and watch the scss/jade files for changes
*/
gulp.task('default', ['sass', 'templates'], function () {
browserSync({server: './dist'});
gulp.watch('./src/scss/*.scss', ['sass']);
gulp.watch('./src/*.jade', ['jade-watch']);
gulp.watch('./src/img/**/*', ['images']);
});
function swallowError (error) {
// If you want details of the error in the console
console.log(error.toString())
this.emit('end')
}