-
Notifications
You must be signed in to change notification settings - Fork 45
/
gulpfile.js
111 lines (90 loc) · 3.2 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var concatVendor = require('gulp-concat-vendor');
var uglify = require('gulp-uglify');
var minify = require('gulp-minify-css')
var mainBowerFiles = require('main-bower-files');
var inject = require('gulp-inject');
var runSequence = require('run-sequence');
var gzip = require('gulp-gzip');
var clone = require('gulp-clone');
var order = require('gulp-order');
var series = require('stream-series');
var flatten = require('gulp-flatten');
var rimraf = require('gulp-rimraf');
var debug = require('gulp-debug');
var uncss = require('gulp-uncss');
var vendorJs;
var vendorCss;
options = {
html: ['src/main/webapp//**/*.html'],
ignore: [
'.show',
'.hide',
/\w\.in/,
'.fade',
'.collapse',
'.collapsing',
/(#|\.)has-error(\-[a-zA-Z]+)?/,
/(#|\.)navbar(\-[a-zA-Z]+)?/,
/(#|\.)dropdown(\-[a-zA-Z]+)?/,
/(#|\.)is(\-[a-zA-Z]+)?/,
/(#|\.)checkbox(\-[a-zA-Z]+)?/,
/(#|\.)swagger(\-[a-zA-Z]+)?/,
/(#|\.)pull(\-[a-zA-Z]+)?/,
/(#|\.)list(\-[a-zA-Z]+)?/,
/(#|\.)(open)/,
/(#|\.)ripple(\-[a-zA-Z]+)?/,
'.clearfix',
'.three-dots-row-spinner',
'rotateplane'],
report : true
};
//// Watch Files For Changes
//gulp.task('watch', function() {
// gulp.watch('css/*.css', 'styles');
// gulp.watch('js/*.js', 'scripts');
//});
gulp.task('clean', function () {
return gulp.src('src/main/webapp/resources/vendor', {read: false})
.pipe(rimraf());
});
gulp.task('lib-js-files', function () {
vendorJs = gulp.src(mainBowerFiles('**/*.js'), {base: 'bower_components'})
.pipe(debug({title: 'lib-js-files :'}))
.pipe(concatVendor('lib.min.js'))
.pipe(uglify())
.pipe(gulp.dest('src/main/webapp/resources/vendor/js'));
vendorJs.pipe(clone())
.pipe(gzip())
.pipe(gulp.dest('src/main/webapp/resources/vendor/js'));
});
gulp.task('lib-css-files', function () {
vendorCss = gulp.src(mainBowerFiles('**/*.css'), {base: 'bower_components'})
.pipe(uncss(options))
.pipe(debug({title: 'lib-css-files :'}))
.pipe(minify())
.pipe(concat('lib.min.css'))
.pipe(gulp.dest('src/main/webapp/resources/vendor/css'));
vendorCss.pipe(clone())
.pipe(clone())
.pipe(gzip())
.pipe(gulp.dest('src/main/webapp/resources/vendor/css'));
});
gulp.task('index', function () {
var target = gulp.src("src/main/webapp/index.html");
var jsSources = gulp.src(['src/main/webapp/resources/js/*.js'], {read: false})
.pipe(order(["**/security.js", "**/app.js"]));
var cssSources = gulp.src(['src/main/webapp/resources/css/*.css'], {read: false});
return target.pipe(inject(series(vendorJs, vendorCss, jsSources, cssSources), {relative: true}))
.pipe(gulp.dest('src/main/webapp'));
});
gulp.task('copyFonts', function () {
gulp.src('bower_components/**/fonts/*.{ttf,woff,woff2,eof,svg}')
.pipe(flatten())
.pipe(gulp.dest('src/main/webapp/resources/vendor/fonts'));
});
// Default Task
gulp.task('default', function () {
runSequence('clean', 'lib-js-files', 'lib-css-files', 'copyFonts', "index");
});