-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgulpfile.js
293 lines (248 loc) · 9.41 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var compress = require('gulp-compress');
var gzip = require('gulp-gzip');
var rename = require('gulp-rename');
var banner = "";
banner += "/* Gridifier v<%= pkg.version %> custom build.\n";
banner += " * Async Responsive HTML Grids\n";
banner += " * http://gridifier.io\n";
banner += " * \n";
banner += " * Gridifier is dual-licensed:\n";
banner += " * Non-commercial license - https://creativecommons.org/licenses/by-nc-sa/4.0/ \n";
banner += " * Commercial license - http://gridifier.io/license (Commercial license)\n";
banner += " * Read http://gridifier.io/license for details.\n";
banner += " * Copyright " + (new Date()).getFullYear() + " nTech\n";
banner += " */\n\n";
var api = "src/api/";
var core = "src/core/";
// Optional classes
var selectable = [
// Required for renderer antialiasing. (Read http://gridifier.io/api/renderers)
// If you are not using 'width(Px|Pt)As || height(Px|Pt)As', you can comment out next line
core + "core/antialiaser.js",
// Required for horizontal grids. (Read http://gridifier.io/grids/grid-types)
// If you are using only vertical grids, you can comment out next 6 lines.
core + "grid/horizontal/appender.js",
core + "grid/horizontal/connections.js",
core + "grid/horizontal/coordsFinder.js",
core + "grid/horizontal/prepender.js",
core + "grid/horizontal/reversedAppender.js",
core + "grid/horizontal/reversedPrepender.js",
// Required for vertical grids. (Read http://gridifier.io/grids/grid-types)
// If you are using only horizontal grids, you can comment out next 6 lines.
core + "grid/vertical/appender.js",
core + "grid/vertical/connections.js",
core + "grid/vertical/coordsFinder.js",
core + "grid/vertical/prepender.js",
core + "grid/vertical/reversedAppender.js",
core + "grid/vertical/reversedPrepender.js",
// Required for render after silentAppend inserts.
// (Read http://gridifier.io/grids/insert-types)
// If you are not using 'silentAppend/silentRender' fns, you can comment out next line.
core + "renderer/silent.js",
// Required for images loading.
// (Insert operations will wait while all item images are loaded)
// (Read http://gridifier.io/grids/insert-types)
// If you aren't using 'loadImages: true' setting, you can comment out next 2 lines.
core + "images/image.js",
core + "images/loader.js",
// Required for dragifiers.
// (Read http://gridifier.io/dragifiers)
// If you are not using dragifiers, you can comment out next 3 lines.
core + "dragifier/core.js",
core + "dragifier/dragifier.js",
api + "dragifier/dragifier.js",
// Required for intersection dragifiers.
// (Read http://gridifier.io/dragifiers)
// If you are using only discretization dragifiers or not
// using dragifiers, you can comment out next line.
core + "dragifier/intersection/item.js",
// Required for discretization dragifiers.
// (Read http://gridifier.io/dragifiers)
// If you are using only intersection dragifiers or not
// using dragifiers, you can comment out next 4 lines.
core + "discretizer/core.js",
core + "discretizer/discretizer.js",
core + "dragifier/discretization/cells.js",
core + "dragifier/discretization/item.js",
// Required for coords changer drivers.
// (Read http://gridifier.io/api/renderers)
// If you are not using position/translate coords changers,
// you can comment out next 2 lines.
api + "coordsChanger/position.js",
api + "coordsChanger/translate.js",
// Required for using built-in rsort functions.
// (Read http://gridifier.io/sortings/retransform-sorts)
// If you are not using areaEvenly, area(Asc|Desc) and other fns,
// you can comment out next line.
api + "sort/rsortHelpers.js",
// Required for using sort helper object functions.
// (Passed as 3-rd param in all sort fn-s by default)
// (Read http://gridifier.io/sortings/sorts)
// If you are not using sort helper object, you can comment out next line.
api + "sort/sortHelpers.js",
// Required for using rotate toggler fns. (Read http://gridifier.io/api/togglers)
// If you are not using them, you can comment out next 2 lines.
api + "toggle/factory/rotate.js",
api + "toggle/rotate.js",
// Required for using scale toggler fns. (Read http://gridifier.io/api/togglers)
// If you are not using them, you can comment out next 2 lines.
api + "toggle/factory/scale.js",
api + "toggle/scale.js",
// Required for using slide toggler fns. (Read http://gridifier.io/api/togglers)
// If you are not using them, you can comment out next 2 lines.
api + "toggle/factory/slide.js",
api + "toggle/slide.js",
// Required for fade toggler.
api + "toggle/fade.js"
];
// Required classes
var required = [
// Loader start
core + "loader/loaderPrefix.js",
// Bootstrap start
core + "bootstrap/funcs.js",
core + "bootstrap/mocks.js",
core + "bootstrap/vars.js",
// Sizes Resolver
core + "bootstrap/sizesResolver/sizesResolver.js",
core + "bootstrap/sizesResolver/init.js",
core + "bootstrap/sizesResolver/outerWidth.js",
core + "bootstrap/sizesResolver/outerHeight.js",
// Bootstrap end
core + "bootstrap/event.js",
core + "bootstrap/prefixer.js",
core + "bootstrap/dom.js",
// Connections
core + "core/connections/connections.js",
core + "core/connections/intersector.js",
core + "core/connections/ranges.js",
core + "core/connections/sorter.js",
core + "core/connections/xyIntersector.js",
// Connectors
core + "core/connectors/cleaner.js",
core + "core/connectors/connectors.js",
core + "core/connectors/intersector.js",
core + "core/connectors/reposition.js",
core + "core/connectors/rounder.js",
core + "core/connectors/selector.js",
core + "core/connectors/shifter.js",
core + "core/connectors/sorter.js",
// Item
core + "core/item/collector.js",
core + "core/item/guid.js",
core + "core/item/item.js",
// Managers
core + "core/manager/cssManager.js",
core + "core/manager/srManager.js",
// Operations
core + "core/operation/disconnector.js",
core + "core/operation/filtrator.js",
core + "core/operation/resorter.js",
// Core
core + "core/core.js",
core + "core/eventEmitter.js",
core + "core/iterator.js",
core + "core/operation.js",
core + "core/position.js",
core + "core/rounder.js",
// Grid
core + "grid/grid.js",
// Insert
core + "inserter/append.js",
core + "inserter/insert.js",
core + "inserter/prepend.js",
core + "inserter/queue.js",
// Renderer
core + "renderer/connections.js",
core + "renderer/queue.js",
core + "renderer/renderer.js",
// Reposition
core + "reposition/data.js",
core + "reposition/queue.js",
core + "reposition/reposition.js",
// Coords changer
api + "coordsChanger/coordsChanger.js",
api + "coordsChanger/default.js",
// Settings
api + "settings/settings.js",
api + "settings/funcs.js",
// Rsort
api + "sort/rsort.js",
// Toggle
api + "toggle/toggle.js",
api + "toggle/syncer.js",
api + "toggle/visibility.js"
];
var loader = [
// Objects builder
core + "gridifier.js",
// Loader end
core + "loader/loaderPostfix.js"
];
var buildSrcFiles = [];
for(var i = 0; i < required.length; i++)
buildSrcFiles.push(required[i]);
for(var i = 0; i < selectable.length; i++)
buildSrcFiles.push(selectable[i]);
for(var i = 0; i < loader.length; i++)
buildSrcFiles.push(loader[i]);
gulp.task('concat', function () {
return gulp
.src(buildSrcFiles, {base: 'src/'})
.pipe(concat('gridifier-custom.js'))
.pipe(gulp.dest('dist'))
;
});
var preserves = 0;
gulp.task('compress', ['concat'], function () {
return gulp
.src('dist/gridifier-custom.js')
.pipe(uglify({
preserveComments: function(node, comment) {
if(preserves == 1) return false;
if(/(.*)comment(.*)/i.test(comment.type)) {
if(/Gridifier/i.test(comment.value)) {
preserves++;
return true;
}
else
return false;
}
},
output: {beautify: true}
}))
.pipe(gulp.dest('dist'))
;
});
var minPreserves = 0;
gulp.task('compress-min', ['concat', 'compress'], function () {
return gulp
.src('dist/gridifier-custom.js')
.pipe(uglify({
preserveComments: function(node, comment) {
if(minPreserves == 1) return false;
if(/(.*)comment(.*)/i.test(comment.type)) {
if(/Gridifier/i.test(comment.value)) {
minPreserves++;
return true;
}
else
return false;
}
}
}))
.pipe(rename('gridifier-custom.min.js'))
.pipe(gulp.dest('dist'))
;
});
gulp.task('zip', ['concat', 'compress', 'compress-min'], function() {
gulp.src('dist/gridifier-custom.min.js')
.pipe(gzip())
.pipe(rename('gridifier-custom.min.js.gz'))
.pipe(gulp.dest('dist/gzip'))
;
});
gulp.task('default', ["concat", "compress", "compress-min", "zip"]);