-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
153 lines (134 loc) · 3.74 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
var del = require('del');
var path = require('path');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var watch = require('gulp-watch');
var nodemon = require('gulp-nodemon');
var mincss = require('gulp-minify-css');
var rename = require('gulp-rename');
var clone = require('gulp-clone');
var order = require('gulp-order');
var debug = require('gulp-debug');
var sourcemaps = require('gulp-sourcemaps');
var es = require('event-stream');
gulp.task('build-client-css', function() {
var allCSS = gulp.src([
// all css files
path.join(
__dirname,
'client',
'css',
'**',
'*.css'
)
])
.pipe(concat('app.css'));
var minCSS = allCSS.pipe(clone())
.pipe(sourcemaps.init())
.pipe(mincss())
.pipe(sourcemaps.write())
.pipe(rename('app.min.css'));
return es.merge(allCSS, minCSS)
.pipe(gulp.dest(
path.join(
__dirname,
'client',
'build'
)
));
});
gulp.task('build-client-js', function(){
// write all files, in order to a concat file
var allJS = gulp.src([
path.join(
__dirname,
'client',
'js',
'**',
'*.js'
)
]).
pipe(order([
'd3/*.js',
'angular/wikitree.module.js',
'angular/wikitree.routes.js',
'angular/services/*.js',
'angular/search/*.module.js',
'angular/search/*.js',
'angular/home/*.module.js',
'angular/home/*.js',
'angular/session/*.module.js',
'angular/session/*.js',
'angular/session/menu/*.module.js',
'angular/session/menu/*.js',
'angular/session/menu/session_tile/*.module.js',
'angular/session/menu/session_tile/*.js',
'angular/session/reader/*.module.js',
'angular/session/reader/*.js',
'angular/session/reader/editor/*.module.js',
'angular/session/reader/editor/*.js',
'angular/session/graph/*.module.js',
'angular/session/graph/*.js',
'angular/session/resizer/*.module.js',
'angular/session/resizer/*.js'
]))
.pipe(concat('app.js'));
// copy the concat file, uglify and rename
var minJS = allJS.pipe(clone())
.pipe(uglify().on('error', console.log))
.pipe(rename('app.min.js'));
// merge the two files to one dest
return es.merge(allJS, minJS)
.pipe(gulp.dest(
path.join(
__dirname,
'client',
'build'
)
));
});
gulp.task('build', ['build-client-css', 'build-client-js'], function(){
return;
});
gulp.task('clean',function(cb) {
del(['client/build/**/*'], cb);
});
gulp.task('dev', function() {
// runs nodemon on the server file and executed the default task
nodemon({
script: path.join(
__dirname,
'server',
'server.js'
),
ext: 'js',
ignore: ['node_modules/**']
}).on('restart', ['default']);
gulp.start('default');
});
gulp.task('default', ['clean'], function(){
gulp.start('build');
watch(path.join(
__dirname,
'client',
'js',
'**',
'*.js'
), function() {
gulp.start('build-client-js');
});
watch(path.join(
__dirname,
'client',
'css',
'**',
'*.css'
), function() {
gulp.start('build-client-css');
});
});
// ** stub for running unit & integration tests
gulp.task('test', function(){
return;
});