-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·116 lines (104 loc) · 2.7 KB
/
Copy pathgulpfile.js
File metadata and controls
executable file
·116 lines (104 loc) · 2.7 KB
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
106
107
108
109
110
111
112
113
114
115
116
// Require
var gulp = require('gulp'),
bSync = require('browser-sync'),
toys = require('gulp-load-plugins')(); // Auto require for package.json
// Setting
var rootDir = './',
rootSrc = rootDir + 'src/',
rootDist = rootDir + 'dist/Electron\.app/Contents/Resources/default_app/',
ignoreTypes = 'styl|coffee|jade',
conf = {
copy: {
watch: rootSrc + '**/*.!(' + ignoreTypes + ')',
src : rootSrc + '**/*.!(' + ignoreTypes + ')',
dist : rootDist
}
};
// Auto Setting
(function() {
var i, type,
ignoreTypeList = ignoreTypes.split('|');
for (i in ignoreTypeList) {
type = ignoreTypeList[i];
if (!conf[type]) {
conf[type] = {
watch: rootSrc + '**/*.' + type,
src : rootSrc + '**/*.' + type,
dist : rootDist
}
}
}
})();
// Server
var reload = bSync({
server: {
baseDir: rootDist,
directory: true
},
port: 8181,
open: false,
injectChanges: true,
ghostMode: false,
ui: false
}).reload;
// ### Tasks ### //
// Copy
gulp.task('copy', function() {
gulp.src(conf.copy.src)
.pipe(toys.plumber())
.pipe(toys.cached(conf.copy.dist))
.pipe(gulp.dest(conf.copy.dist))
.pipe(reload({stream: true}));
});
// Stylus
gulp.task('stylus', function () {
gulp.src(conf.styl.src)
.pipe(toys.plumber())
.pipe(toys.cached(conf.styl.dist))
.pipe(toys.stylus())
.pipe(gulp.dest(conf.styl.dist))
.pipe(reload({stream: true}))
.pipe(toys.rename({ suffix: '.min' }))
.pipe(toys.minifyCss({ keepBreaks: true }))
.pipe(gulp.dest(conf.styl.dist))
.pipe(reload({stream: true}));
});
// Coffee
gulp.task('coffee', function () {
gulp.src(conf.coffee.src)
.pipe(toys.plumber())
.pipe(toys.cached(conf.coffee.dist))
.pipe(toys.coffee())
.pipe(toys.jshint('jshintrc.json'))
.pipe(toys.jshint.reporter('default'))
.pipe(gulp.dest(conf.coffee.dist))
.pipe(reload({stream: true}))
.pipe(toys.rename({ suffix: '.min' }))
.pipe(toys.uglify())
.pipe(gulp.dest(conf.coffee.dist))
.pipe(reload({stream: true}));
});
// Jade
gulp.task('jade', function() {
gulp.src(conf.jade.src)
.pipe(toys.plumber())
.pipe(toys.cached(conf.jade.dist))
.pipe(toys.jade({pretty: true}))
.pipe(gulp.dest(conf.jade.dist))
.pipe(reload({stream: true}));
});
// Watch
gulp.task('watch', function(){
// Copy
gulp.watch(conf.copy.watch, ['copy']);
// Stylus
gulp.watch(conf.styl.watch, ['stylus']);
// Coffee
gulp.watch(conf.coffee.watch, ['coffee']);
// Jade
gulp.watch(conf.jade.watch, ['jade']);
});
// Default Task
gulp.task('default', function(){
gulp.start(['copy', 'stylus', 'coffee', 'jade', 'watch']);
});