gulpfile.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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', function () {
  13. gulp.src('./js/script.js')
  14. .pipe(jsmin())
  15. .pipe(rename({suffix: '.min'}))
  16. .pipe(gulp.dest('./js/'));
  17. });
  18. gulp.task('styles', function () {
  19. gulp.src('./scss/styles.scss')
  20. .pipe(sass().on('error', sass.logError))
  21. // .pipe(gulp.dest('./css/'));
  22. // gulp.src('./css/*.css')
  23. .pipe(autoprefixer({
  24. browsers: ['last 2 versions'],
  25. cascade: false
  26. })).on('error', handleError)
  27. .pipe(gulp.dest('./css/'));
  28. });
  29. gulp.task('default', function () {
  30. });
  31. // default gulp task
  32. gulp.task('default', ['scripts', 'styles'], function() {
  33. gulp.watch('./scss/*.scss', ['styles']);
  34. gulp.watch('./js/script.js', ['scripts']);
  35. });