This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 195
/
gulpfile.js
79 lines (68 loc) · 2.24 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
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var mainBowerFiles = require('main-bower-files');
var del = require('del');
var runSequence = require('run-sequence');
function js(shouldMinify) {
return gulp.src(mainBowerFiles().concat([ // not taking wildcards
'./webserver/public/js/controllers/**',
'./webserver/public/js/charting/**',
'./webserver/public/js/directives/**',
'./webserver/public/js/**'
]))
.pipe(plugins.filter('*.js'))
.pipe(plugins.concat('scripts.js'))
.pipe(plugins.if(shouldMinify, plugins.ngAnnotate()))
.pipe(plugins.if(shouldMinify, plugins.uglify()))
.pipe(gulp.dest('./webserver/public/build'));
}
function css(shouldMinify) {
return gulp.src(mainBowerFiles().concat(['./webserver/public/less/*.less']))
.pipe(plugins.filter(['*.css', '*.less']))
.pipe(plugins.less())
.pipe(plugins.concat('style.css'))
.pipe(plugins.if(shouldMinify, plugins.minifyCss({keepBreaks: true})))
.pipe(gulp.dest('./webserver/public/build'));
}
gulp.task('clean', function () {
return del([
'./webserver/public/build/*',
'./webserver/public/fonts/*'
]);
});
gulp.task('copy-fonts', function () {
return gulp.src('./webserver/public/bower_components/bootstrap/fonts/*')
.pipe(plugins.copy('./webserver/public/fonts/', {prefix: 5}));
});
gulp.task('lint', function () {
return gulp.src([
'./webserver/**/*.js',
'!./webserver/public/bower_components/**/*.js',
'!./webserver/public/build/**/*.js',
'./lib/**/*.js',
'./test/**/*.js',
'./config/**/*.js',
'./scripts/**/*.js',
'./*.js'
])
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('default'));
});
gulp.task('js-dev', function () {
return js(false);
});
gulp.task('js-prod', function () {
return js(true);
});
gulp.task('css-prod', function () {
return css(true);
});
gulp.task('build', function () {
return runSequence('clean', ['copy-fonts', 'js-prod', 'css-prod']);
});
gulp.task('watch', function () {
gulp.watch('./webserver/public/bower_components/**/*', ['css-prod', 'js-dev']);
gulp.watch('./webserver/public/js/**', ['js-dev']);
gulp.watch('./webserver/public/less/*', ['css-prod']);
});
gulp.task('default', ['build']);