-
Notifications
You must be signed in to change notification settings - Fork 125
/
gulpfile.js
176 lines (152 loc) · 4.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
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
'use strict';
var gulp = require('gulp'),
concat = require('gulp-concat'),
composer = require('gulp-uglify/composer'),
uglifyjs = require('uglify-js'),
pump = require('pump'),
uglifycss = require('gulp-uglifycss'),
rename = require('gulp-rename'),
del = require('del'),
flatten = require('gulp-flatten'),
zip = require('gulp-zip'),
watch = require('gulp-watch');
var minify = composer(uglifyjs, console);
//Building only primeui.js in watch mode
gulp.task('build-js-w', function() {
return watch([
'components/core/core.js',
'components/**/*.js'
], function() {
gulp.src([
'components/core/core.js',
'components/**/*.js'
])
.pipe(concat('primeui.js'))
.pipe(gulp.dest('build'));
});
});
gulp.task('build-watch', function() {
return watch([
'components/core/core.js',
'components/**/*.js',
'components/**/*.css'
], function() {
gulp.src([
'components/core/core.js',
'components/**/*.js',
])
.pipe(concat('primeui.js'))
.pipe(gulp.dest('build'));
gulp.src([
'components/**/*.css'
])
.pipe(concat('primeui.css'))
.pipe(gulp.dest('build'));
});
});
//Building only primeui.js
gulp.task('build-js', function() {
gulp.src([
'components/core/core.js',
'components/**/*.js'
])
.pipe(concat('primeui.js'))
.pipe(gulp.dest('build'));
});
//Building only primeui.css
gulp.task('build-css', function() {
gulp.src([
'components/**/*.css'
])
.pipe(concat('primeui.css'))
.pipe(gulp.dest('build'));
});
//Building primeui.js, primeui.css at the same time
gulp.task('build-dev', ['build-js', 'build-css']);
//Building images
gulp.task('images', function() {
return gulp.src(['components/**/images/*.png', 'components/**/images/*.gif'])
.pipe(flatten())
.pipe(gulp.dest('build/images'));
});
//Building themes
gulp.task('themes', function () {
return gulp.src(['showcase/themes/**/*'])
.pipe(gulp.dest('build/themes'));
});
//Building plugins
gulp.task('plugins', function () {
return gulp.src(['showcase/resources/js/plugins/*.js'])
.pipe(gulp.dest('build/plugins'));
});
//Building primeui.js and primeui.min.js
gulp.task('build-js-prod', function(cb) {
var options = {};
pump([
gulp.src([
'components/core/core.js',
'components/**/*.js'
]),
concat('primeui.js'),
gulp.dest('build'),
minify(options),
rename('primeui.min.js'),
gulp.dest('build')
],
cb);
});
//Building primeui.css and primeui.min.css
gulp.task('build-css-prod', function() {
gulp.src([
'components/**/*.css'
])
.pipe(concat('primeui.css'))
.pipe(gulp.dest('build'))
.pipe(uglifycss({"uglyComments": true}))
.pipe(rename('primeui.min.css'))
.pipe(gulp.dest('build'));
});
//Build primeui-all.js
gulp.task('build-primeui-js-all', function(cb) {
var options = {compress: {hoist_funs: false, hoist_vars: false}};
pump([
gulp.src([
'showcase/resources/js/jquery.js',
'showcase/resources/js/jquery-ui.js',
'components/core/core.js',
'components/**/*.js'
]),
concat('primeui-all.js'),
gulp.dest('build'),
minify(options),
rename('primeui-all.min.js'),
gulp.dest('build')
],
cb);
});
//Build primeui-all.css
gulp.task('build-primeui-css-all', function() {
gulp.src([
'showcase/resources/css/jquery-ui.css',
'components/**/*.css'
])
.pipe(concat('primeui-all.css'))
.pipe(gulp.dest('build'))
.pipe(uglifycss({"uglyComments": true}))
.pipe(rename('primeui-all.min.css'))
.pipe(gulp.dest('build'));
});
//Cleaning previous gulp tasks from project
gulp.task('clean', function() {
del(['build']);
});
//Building project with run sequence
gulp.task('build-all', ['build-js-prod', 'build-css-prod',
'build-primeui-js-all', 'build-primeui-css-all',
'images','themes','plugins']);
//Building distribution version with zip folder
gulp.task('distribute', ['build-all'], function() {
return gulp.src('build/**/*')
.pipe(zip('primeui.zip'))
.pipe(gulp.dest('build'));
})