|
22 | 22 | styles: 'build/css/',
|
23 | 23 | scripts: 'build/js/'
|
24 | 24 | },
|
| 25 | + custom: { |
| 26 | + root: 'custom/', |
| 27 | + styles: 'custom/css/', |
| 28 | + scripts: 'custom/js/' |
| 29 | + }, |
25 | 30 | dist: {
|
26 | 31 | root: 'dist/',
|
27 | 32 | styles: 'dist/css/',
|
|
114 | 119 | 'src/js/wrap-end-umd.js',
|
115 | 120 | ],
|
116 | 121 | Framework7Files : [
|
117 |
| - 'src/js/swiper-intro-f7.js', |
| 122 | + 'src/js/swiper-intro-swiper.js', |
118 | 123 | 'src/js/core.js',
|
119 | 124 | 'src/js/effects.js',
|
120 | 125 | 'src/js/lazy-load.js',
|
|
130 | 135 | 'src/js/swiper-proto.js',
|
131 | 136 | ],
|
132 | 137 | pkg: require('./bower.json'),
|
| 138 | + modules: require('./modules.json'), |
133 | 139 | banner: [
|
134 | 140 | '/**',
|
135 | 141 | ' * Swiper <%= pkg.version %>',
|
|
146 | 152 | ' * Released on: <%= date.month %> <%= date.day %>, <%= date.year %>',
|
147 | 153 | ' */',
|
148 | 154 | ''].join('\n'),
|
| 155 | + customBanner: [ |
| 156 | + '/**', |
| 157 | + ' * Swiper <%= pkg.version %> - Custom Build', |
| 158 | + ' * <%= pkg.description %>', |
| 159 | + ' * ', |
| 160 | + ' * Included modules: <%= modulesList %>', |
| 161 | + ' * ', |
| 162 | + ' * <%= pkg.homepage %>', |
| 163 | + ' * ', |
| 164 | + ' * Copyright <%= date.year %>, <%= pkg.author %>', |
| 165 | + ' * The iDangero.us', |
| 166 | + ' * http://www.idangero.us/', |
| 167 | + ' * ', |
| 168 | + ' * Licensed under <%= pkg.license.join(" & ") %>', |
| 169 | + ' * ', |
| 170 | + ' * Released on: <%= date.month %> <%= date.day %>, <%= date.year %>', |
| 171 | + ' */', |
| 172 | + ''].join('\n'), |
149 | 173 | date: {
|
150 | 174 | year: new Date().getFullYear(),
|
151 | 175 | month: ('January February March April May June July August September October November December').split(' ')[new Date().getMonth()],
|
|
159 | 183 | if (['wrap-start.js', 'wrap-start-umd.js', 'wrap-end.js', 'wrap-end-umd.js', 'amd.js'].indexOf(filename) !== -1) {
|
160 | 184 | addIndent = '';
|
161 | 185 | }
|
162 |
| - if (filename === 'swiper-intro.js' || filename === 'swiper-intro-f7.js' || filename === 'swiper-outro.js' || filename === 'dom.js' || filename === 'get-dom-lib.js' || filename === 'get-jquery.js' || filename === 'dom-plugins.js' || filename === 'swiper-proto.js') addIndent = ' '; |
| 186 | + if (filename === 'swiper-intro.js' || filename === 'swiper-intro-swiper.js' || filename === 'swiper-outro.js' || filename === 'dom.js' || filename === 'get-dom-lib.js' || filename === 'get-jquery.js' || filename === 'dom-plugins.js' || filename === 'swiper-proto.js') addIndent = ' '; |
163 | 187 | if (minusIndent) {
|
164 | 188 | addIndent = addIndent.substring(4);
|
165 | 189 | }
|
|
231 | 255 |
|
232 | 256 | gulp.src([
|
233 | 257 | paths.source.styles + 'core.less',
|
234 |
| - paths.source.styles + 'navigation-f7.less', |
| 258 | + paths.source.styles + 'navigation-swiper.less', |
235 | 259 | paths.source.styles + 'effects.less',
|
236 | 260 | paths.source.styles + 'scrollbar.less',
|
237 |
| - paths.source.styles + 'preloader-f7.less', |
| 261 | + paths.source.styles + 'preloader-swiper.less', |
238 | 262 | ])
|
239 | 263 | .pipe(concat(swiper.filename + '.framework7.less'))
|
240 | 264 | .pipe(header('/* === Swiper === */\n'))
|
|
292 | 316 | .pipe(gulp.dest(paths.dist.styles));
|
293 | 317 | });
|
294 | 318 |
|
| 319 | + /* ================================= |
| 320 | + Custom Build |
| 321 | + ================================= */ |
| 322 | + gulp.task('custom', function () { |
| 323 | + var modules = process.argv.slice(3); |
| 324 | + modules = modules.toString(); |
| 325 | + if (modules === '') { |
| 326 | + modules = []; |
| 327 | + } |
| 328 | + else { |
| 329 | + modules = modules.substring(1).replace(/ /g, '').replace(/,,/g, ','); |
| 330 | + modules = modules.split(','); |
| 331 | + } |
| 332 | + var modulesJs = [], modulesLess = []; |
| 333 | + var i, module; |
| 334 | + modulesJs.push.apply(modulesJs, swiper.modules.core_intro.js); |
| 335 | + modulesLess.push.apply(modulesLess, swiper.modules.core_intro.less); |
| 336 | + |
| 337 | + for (i = 0; i < modules.length; i++) { |
| 338 | + module = swiper.modules[modules[i]]; |
| 339 | + if (!(module)) continue; |
| 340 | + |
| 341 | + if (module.dependencies && module.dependencies.length > 0) { |
| 342 | + modules.push.apply(modules, module.dependencies); |
| 343 | + } |
| 344 | + if (module.js.length > 0) { |
| 345 | + modulesJs.push.apply(modulesJs, module.js); |
| 346 | + } |
| 347 | + if (module.less && module.less.length > 0) { |
| 348 | + modulesLess.push.apply(modulesLess, module.less); |
| 349 | + } |
| 350 | + } |
| 351 | + modulesJs.push.apply(modulesJs, swiper.modules.core_outro.js); |
| 352 | + modulesLess.push.apply(modulesLess, swiper.modules.core_outro.less); |
| 353 | + |
| 354 | + // Unique |
| 355 | + var customJsList = []; |
| 356 | + var customLessList = []; |
| 357 | + for (i = 0; i < modulesJs.length; i++) { |
| 358 | + if (customJsList.indexOf(modulesJs[i]) < 0) customJsList.push(modulesJs[i]); |
| 359 | + } |
| 360 | + for (i = 0; i < modulesLess.length; i++) { |
| 361 | + if (customLessList.indexOf(modulesLess[i]) < 0) customLessList.push(modulesLess[i]); |
| 362 | + } |
| 363 | + |
| 364 | + // JS |
| 365 | + gulp.src(customJsList) |
| 366 | + .pipe(tap(function (file, t){ |
| 367 | + addJSIndent (file, t); |
| 368 | + })) |
| 369 | + .pipe(concat(swiper.filename + '.custom.js')) |
| 370 | + .pipe(header(swiper.customBanner, { pkg : swiper.pkg, date: swiper.date, modulesList: modules.join(',') } )) |
| 371 | + .pipe(jshint()) |
| 372 | + .pipe(jshint.reporter(stylish)) |
| 373 | + .pipe(gulp.dest(paths.custom.scripts)) |
| 374 | + |
| 375 | + .pipe(uglify()) |
| 376 | + .pipe(header(swiper.customBanner, { pkg : swiper.pkg, date: swiper.date, modulesList: modules.join(',') })) |
| 377 | + .pipe(rename(function(path) { |
| 378 | + path.basename = path.basename + '.min'; |
| 379 | + })) |
| 380 | + .pipe(gulp.dest(paths.custom.scripts)); |
| 381 | + |
| 382 | + // CSSes |
| 383 | + gulp.src(customLessList) |
| 384 | + .pipe(concat(swiper.filename + '.custom.less')) |
| 385 | + .pipe(less({ |
| 386 | + paths: [ path.join(__dirname, 'less', 'includes') ] |
| 387 | + })) |
| 388 | + .pipe(header(swiper.customBanner, { pkg : swiper.pkg, date: swiper.date, modulesList: modules.join(',') } )) |
| 389 | + .pipe(gulp.dest(paths.custom.styles)) |
| 390 | + |
| 391 | + .pipe(cleanCSS({ |
| 392 | + advanced: false, |
| 393 | + aggressiveMerging: false |
| 394 | + })) |
| 395 | + .pipe(header(swiper.customBanner, { pkg : swiper.pkg, date: swiper.date, modulesList: modules.join(',') })) |
| 396 | + .pipe(rename(function(path) { |
| 397 | + path.basename = path.basename + '.min'; |
| 398 | + })) |
| 399 | + .pipe(gulp.dest(paths.custom.styles)); |
| 400 | + }); |
| 401 | + |
295 | 402 | gulp.task('watch', function () {
|
296 | 403 | gulp.watch(paths.source.scripts, [ 'scripts' ]);
|
297 | 404 | gulp.watch(paths.source.styles + '*.less', [ 'styles' ]);
|
|
0 commit comments