Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 1 | /*eslint-env node */ |
| 2 | /*global require: true, module: true */ |
| 3 | |
| 4 | 'use strict'; |
| 5 | |
| 6 | var options = require('../gulp-options.js'), |
| 7 | gulp = require('gulp'), |
| 8 | clean = require('gulp-clean'), |
| 9 | webapp = require('./webapp.js'), |
| 10 | imagemin = require('gulp-imagemin'); |
| 11 | |
| 12 | var runSequence = require('run-sequence'); |
| 13 | |
| 14 | gulp.task('webapp', function (callback) { |
| 15 | return webapp(callback); |
| 16 | }); |
| 17 | |
| 18 | gulp.task('distribution:clean', function () { |
| 19 | return gulp |
| 20 | .src([options.dirname + '/dist'], { 'read': false }) |
| 21 | .pipe(clean({'force': true})); |
| 22 | }); |
| 23 | |
| 24 | gulp.task('distribution:copy', function () { |
| 25 | return gulp |
| 26 | .src(['**/*'], { 'cwd': options.targetFolderPath + '/webapp' }) |
| 27 | .pipe(gulp.dest(options.dirname + '/dist')); |
| 28 | }); |
| 29 | |
| 30 | gulp.task('imagemin', () => |
| 31 | gulp.src([options.dirname + '/app/assets/images/*']) |
| 32 | .pipe(imagemin({ |
| 33 | optimizationLevel: 3, |
| 34 | progressive: true, |
| 35 | interlaced: false, |
| 36 | svgoPlugins: [{ |
| 37 | removeViewBox: false |
| 38 | }] |
| 39 | })) |
| 40 | .pipe(gulp.dest('dist/assets/images')) |
| 41 | ); |
| 42 | |
| 43 | module.exports = function (callback) { |
| 44 | return runSequence('distribution:clean', 'webapp', 'distribution:copy', 'imagemin', callback); |
| 45 | }; |