gulpfile.js 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. var gulp = require('gulp');
  3. var sass = require('gulp-sass');
  4. var watch = require('gulp-watch');
  5. var autoprefixer = require('gulp-autoprefixer');
  6. var jsmin = require('gulp-jsmin');
  7. var rename = require('gulp-rename');
  8. function handleError(err) {
  9. console.log(err.toString());
  10. // this.emit('end');
  11. }
  12. gulp.task('scripts', done => {
  13. gulp.src('./js/script.js')
  14. .pipe(jsmin())
  15. .pipe(rename({suffix: '.min'}))
  16. .pipe(gulp.dest('./js/'));
  17. done();
  18. });
  19. gulp.task('styles', done => {
  20. gulp.src('./scss/styles.scss')
  21. .pipe(sass().on('error', sass.logError))
  22. // .pipe(gulp.dest('./css/'));
  23. // gulp.src('./css/*.css')
  24. .pipe(autoprefixer({
  25. cascade: false
  26. })).on('error', handleError)
  27. .pipe(gulp.dest('./css/'));
  28. done();
  29. });
  30. // default gulp task
  31. gulp.task('default', gulp.series('scripts', 'styles', function(done) {
  32. gulp.watch('./scss/*.scss', gulp.series('styles'));
  33. gulp.watch('./js/script.js', gulp.series('scripts'));
  34. done()
  35. }));