This repository has been archived by the owner on Oct 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
gulpfile.js
218 lines (211 loc) · 6.65 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
var gulp = require('gulp-param')(require('gulp'), process.argv);
var jade = require('gulp-jade');
var uglify = require('gulp-uglify');
var less = require('gulp-less');
var concat = require('gulp-concat');
var gettext = require('gulp-angular-gettext');
var gulpif = require('gulp-if');
var ngConstant = require('gulp-ng-constant');
var remember = require('gulp-remember');
var cache = require('gulp-cached');
var newer = require('gulp-newer');
var streamqueue = require('streamqueue');
var rename = require('gulp-rename');
var es = require('event-stream');
var gulpSharp = require('gulp-sharp');
gulp.task('html', function(config) {
config = JSON.parse(config);
var languages = require('./frontend/languages.json');
config.languages = languages;
return gulp.src('./frontend/**/*.jade')
.pipe(jade({
locals: config
}))
.pipe(gulp.dest(config.staticContent));
});
gulp.task('js', function(config) {
config = JSON.parse(config);
return streamqueue({objectMode: true},
gulp.src([
'node_modules/angular/angular.min.js',
'node_modules/angular-route/angular-route.js',
'node_modules/angular-gettext/dist/angular-gettext.min.js',
'node_modules/angular-strap/dist/modules/compiler.min.js',
'node_modules/angular-strap/dist/modules/dimensions.min.js',
'node_modules/angular-strap/dist/modules/modal.min.js',
'node_modules/sjcl/sjcl.js',
'node_modules/sjcl/core/codecBytes.js',
'node_modules/clipboard/dist/clipboard.min.js',
'frontend/locales/*.po',
'frontend/scripts/*.js'
]),
ngConstant({
constants: {
config: {
acceptedTypes: config.acceptedTypes,
maxSize: config.maxSize
}
},
stream: true,
name: 'imgbi.config'
})
)
.pipe(cache('scripts'))
.pipe(gulpif(/[.]po$/, gettext.compile()))
.pipe(remember('scripts'))
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(gulp.dest(config.staticContent + '/scripts'));
});
gulp.task('css', function(config) {
config = JSON.parse(config);
return gulp.src('frontend/less/main.less')
.pipe(less({
paths: [
'node_modules/bootstrap/less',
'frontend/less'
]
}))
.pipe(gulp.dest(config.staticContent + '/css'));
});
gulp.task('favicons', function(config) {
config = JSON.parse(config);
return es.merge([
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [57],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('apple-touch-icon-57x57.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [114],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('apple-touch-icon-114x114.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [72],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('apple-touch-icon-72x72.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [144],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('apple-touch-icon-144x144.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [60],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('apple-touch-icon-60x60.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [120],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('apple-touch-icon-120x120.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [76],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('apple-touch-icon-76x76.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [152],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('apple-touch-icon-152x152.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [196],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('favicon-196x196.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [160],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('favicon-160x160.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [96],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('favicon-96x96.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [16],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('favicon-16x16.png'))
.pipe(gulp.dest(config.staticContent + '/icons')),
gulp.src('logo.svg', {read: false})
.pipe(newer(config.staticContent + '/icons'))
.pipe(gulpSharp({
resize: [32],
max: true,
output: 'png',
compressionLevel: 9
}))
.pipe(rename('favicon-32x32.png'))
.pipe(gulp.dest(config.staticContent + '/icons'))
]);
});
gulp.task('fonts', function(config) {
config = JSON.parse(config);
return gulp.src('frontend/font/*')
.pipe(gulp.dest(config.staticContent + '/font'));
});
gulp.task('build', ['css', 'js', 'html', 'favicons', 'fonts']);