/
build.js
99 lines (83 loc) · 2.74 KB
/
build.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
'use strict';
var gulp = require('gulp');
var print = require('gulp-print').default;
var paths = gulp.paths;
var merge = require('merge-stream');
var $ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'main-bower-files', 'uglify-save-license', 'del']
});
gulp.task('html', ['inject'], function(cb) {
var htmlFilter = $.filter('*.html');
var jsFilter = $.filter('**/*.js');
var cssFilter = $.filter('**/*.css');
var gulped = gulp.src(paths.tmp + '/serve/*.jsp')
.pipe($.useref());
// .pipe($.rev())
/* JS COMPRESS */
gulped = gulped.pipe(jsFilter)
.pipe($.ngAnnotate())
.pipe($.cache($.uglify({
preserveComments: $.uglifySaveLicense
}).on('error', function(error) {
console.log("Error: " + error);
cb(error);
})))
.pipe(jsFilter.restore());
/* CSS COMPRESS */
gulped = gulped
.pipe(cssFilter)
.pipe($.cache($.csso())).pipe(cssFilter.restore());
gulped = gulped
.pipe($.useref())
// .pipe($.revReplace())
.pipe(htmlFilter);
gulped = gulped.pipe($.minifyHtml({
empty: true,
spare: true,
quotes: true
}));
return gulped.pipe(htmlFilter.restore())
.pipe(gulp.dest(paths.dist + '/'))
.pipe($.size({
title: paths.dist + '/',
showFiles: true
}));
});
// no compression on js/css
// should also avoid concatenation ...
gulp.task('debug-build', ['inject'], function(cb) {
gulp.src('../../../src/main/webapp/wegas-lobby/**/*.js')
.pipe($.cache($.uglify().on("error", function(error) {
console.log("Error: " + error);
}))).pipe(print());
return gulp.src(paths.tmp + '/serve/*.jsp')
.pipe($.useref())
.pipe(gulp.dest(paths.dist + '/'))
.pipe($.size({
title: paths.dist + '/',
showFiles: true
}));
});
gulp.task('images', function() {
return gulp.src(paths.src + '/assets/images/**/*')
.pipe(gulp.dest(paths.dist + '/assets/images/'));
});
gulp.task('fonts', function() {
var bowerFonts = gulp.src($.mainBowerFiles())
.pipe($.filter('**/*.{eot,svg,ttf,woff}'))
.pipe($.flatten())
.pipe(gulp.dest(paths.dist + '/fonts/'));
var wegasFonts = gulp.src(paths.src + '/assets/fonts/**/*')
.pipe(gulp.dest(paths.dist + '/assets/fonts/'));
return merge(bowerFonts, wegasFonts);
});
gulp.task('misc', function() {
return gulp.src(paths.src + '/**/*.ico')
.pipe(gulp.dest(paths.dist + '/'));
});
gulp.task('clean', function(done) {
$.del([paths.tmp + '/', paths.dist + '/'], done);
});
gulp.task('build', ['html', 'images', 'fonts', 'misc'], function(cb) {
$.del([paths.tmp], cb);
});