-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
90 lines (75 loc) · 2.41 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var gulp = require('gulp');
var ejs = require('gulp-ejs');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var minifyCSS = require('gulp-minify-css');
var del = require('del');
var gcmq = require('gulp-group-css-media-queries');
var neat = require('node-neat').includePaths;
// Not all tasks need to use streams
// A gulpfile is just another node program and you can use all packages available on npm
gulp.task('clean', function(cb) {
// You can use multiple globbing patterns as you would with `gulp.src`
del(['dist'], cb);
});
gulp.task('templates', function() {
gulp.src('./src/templates/*')
.pipe(gulp.dest('./public'));
});
var processStyles = function(stream, options) {
stream = stream.pipe(sourcemaps.init());
if (options.onerror) {
stream.on('error', options.onerror);
}
if (options.postsmCallback) {
stream = options.postsmCallback(stream);
}
stream = stream
.pipe(gcmq());
stream = stream.pipe(minifyCSS({
restructuring: false
}));
stream = stream.pipe(sourcemaps.write());
if (options.destCallback) {
return options.destCallback(stream);
} else {
return stream.pipe(gulp.dest('./dist/web/stylesheets'));
}
};
gulp.task('styles', function() {
var src = gulp.src('./src/styles/*.scss');
return processStyles(src, {
onerror: function(err) {
console.error(err);
},
postsmCallback: function(stream) {
return stream
.pipe(sass({
includePaths: neat
}))
.pipe(concat("style.css"));
},
destCallback: function(stream) {
stream.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./public/css/'));
}
});
});
gulp.task('scripts', function() {
gulp.src('./src/javascripts/**/*')
.pipe(gulp.dest('./public/js/'));
});
gulp.task('vendor', function() {
gulp.src('./vendor/**/*')
.pipe(gulp.dest('./public/libs/'));
});
gulp.task('watch', function() {
gulp.watch('./src/templates/**/*', ['templates']);
gulp.watch('./src/styles/**/*', ['styles']);
gulp.watch('./src/javascripts/**/*', ['scripts']);
gulp.watch('./vendor/**/*', ['vendor']);
});
gulp.task('build', ['templates', 'styles', 'scripts', 'vendor']);
gulp.task('default', ['build', 'watch']);