-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
95 lines (77 loc) · 2.38 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
91
92
93
94
95
var gulp = require('gulp'),
gutil = require('gulp-util'),
coffee = require('gulp-coffee'),
coffeeify = require('gulp-coffeeify'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
test = require('gulp-if'),
del = require('del'),
rename = require('gulp-rename');
var paths = {
scripts: {
main: ['src/coffee/app.coffee'],
listen: ['src/coffee/**/*.coffee'],
out: 'app/assets/js'
},
stylesheets: {
main: ['src/sass/app.sass'],
listen: ['src/sass/**/*.sass'],
out: 'app/assets/css'
}
};
var templates = {
scripts: function (mangle) {
return gulp.src(paths.scripts.main)
.pipe(coffeeify({
options: {
debug: !mangle,
paths: [__dirname + '/node_modules', __dirname + '/src/coffee']
}
}))
.pipe(test(mangle, uglify(), null))
.pipe(gulp.dest(paths.scripts.out));
},
styles: function (compress) {
return gulp.src(paths.stylesheets.main)
.pipe(sass({
outputStyle: (compress ? 'compressed' : 'expanded'),
includePaths: require('node-neat').includePaths.concat(require('node-reset-scss').includePath)
}).on('error', sass.logError))
.pipe(gulp.dest(paths.stylesheets.out));
return stream;
}
};
// Javascript
gulp.task('scripts:compile', ['scripts:clean'], function () {
templates.scripts(false);
});
gulp.task('scripts:build', ['scripts:clean'], function () {
templates.scripts(true);
});
gulp.task('scripts:clean', function () {
del(['app/assets/js/*.js']);
});
gulp.task('scripts:watch', function () {
gulp.watch(paths.scripts.listen, ['scripts:compile']);
});
// Sass
gulp.task('stylesheets:compile', ['stylesheets:clean'], function () {
templates.styles(false);
});
gulp.task('stylesheets:build', ['stylesheets:clean'], function () {
templates.styles(true);
});
gulp.task('stylesheets:clean', function () {
del(['app/assets/css/*.css']);
});
gulp.task('stylesheets:watch', function () {
gulp.watch(paths.stylesheets.listen, ['stylesheets:compile']);
});
// Groups
gulp.task('scripts', ['scripts:watch', 'scripts:compile']);
gulp.task('stylesheets', ['stylesheets:watch', 'stylesheets:compile']);
// Commands
gulp.task('default', ['scripts:compile', 'stylesheets:compile']);
gulp.task('watch', ['scripts', 'stylesheets']);
gulp.task('build', ['scripts:build', 'stylesheets:build']);