gulpfile.js 782 B

123456789101112131415161718192021222324252627282930313233
  1. const gulp = require('gulp');
  2. const uglify = require('gulp-uglify');
  3. const pump = require('pump');
  4. const concat = require('gulp-concat');
  5. const cleanCSS = require('gulp-clean-css');
  6. const fs = require('fs');
  7. const pkg = JSON.parse(fs.readFileSync('./package.json'));
  8. function minifyjs(cb) {
  9. pump([
  10. gulp.src('element.js'),
  11. uglify(),
  12. concat('element-' + pkg.version + '.min.js'),
  13. gulp.dest('dist')
  14. ],
  15. cb);
  16. }
  17. function minifycss() {
  18. return gulp.src('element.css')
  19. .pipe(cleanCSS({compatibility: 'ie8'}))
  20. .pipe(concat('element-' + pkg.version + '.min.css'))
  21. .pipe(gulp.dest('dist'));
  22. }
  23. // Define tasks
  24. gulp.task('minifyjs', minifyjs);
  25. gulp.task('minifycss', minifycss);
  26. // Default task
  27. gulp.task('default', gulp.series('minifyjs', 'minifycss'));