-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
105 lines (87 loc) · 2.12 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
96
97
98
99
100
101
102
103
104
105
// Dependencies
var $ = require('gulp-load-plugins')();
var Gulp = require('gulp');
var Jeet = require('Jeet');
var Rupture = require('rupture');
// Paths
var paths = {
src: {
css: [
'src/bower/font-awesome/css/font-awesome.css',
'src/bower/humane/themes/flatty.css',
'src/bower/spectrum/spectrum.css',
'src/css/main.styl'
],
img: 'src/img/**/*',
fonts: 'src/bower/font-awesome/fonts/**/*',
js: [
'src/bower/react/react.js',
'src/bower/reqwest/reqwest.js',
'src/bower/blueimp-md5/js/md5.js',
'src/bower/humane/humane.js',
'src/bower/spectrum/spectrum.js',
'src/react/app.jsx',
'src/react/admin-bar-nav.jsx',
'src/react/mixins/**/*.jsx',
'src/react/components/**/*.jsx',
'src/js/main.jsx'
]
},
build: {
css: 'assets/css',
fonts: 'assets/fonts',
img: 'assets/img',
js: 'assets/js'
}
};
/**
* Check if is jsx file
* @param {object} Vinyl file object
* @return {boolean}
*/
function isJSX(file) {
var ext = '.jsx';
var startIndex = file.path.length - ext.length;
return file.path.indexOf(ext, startIndex) !== -1 ? true : false;
}
// Default Task
Gulp.task('default', ['css', 'fonts', 'images', 'js']);
// Watch
Gulp.task('watch', function() {
Gulp.watch('src/css/**/*', ['css']);
Gulp.watch(paths.src.img, ['images']);
Gulp.watch(paths.src.js, ['js']);
});
// Process all stylus files
Gulp.task('css', function() {
return Gulp.src(paths.src.css)
.pipe($.plumber())
.pipe($.stylus({
use: [Jeet(), Rupture()],
'include css': true
}))
.pipe($.autoprefixer())
.pipe($.csso())
.pipe($.concat('main.min.css'))
.pipe(Gulp.dest(paths.build.css));
});
// Copy fonts
Gulp.task('fonts', function() {
return Gulp.src(paths.src.fonts)
.pipe(Gulp.dest(paths.build.fonts));
});
// Process all image files
Gulp.task('images', function() {
return Gulp.src(paths.src.img)
.pipe($.plumber())
.pipe(Gulp.dest(paths.build.img));
});
// Process all javascript files
Gulp.task('js', function() {
return Gulp.src(paths.src.js)
.pipe($.plumber())
.pipe($.if(isJSX, $.react()))
.pipe($.concat('main.min.js'))
.pipe($.uglify())
.pipe(Gulp.dest(paths.build.js));
});