gulpfile.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 cleancss = require('gulp-clean-css');
  7. var jsmin = require('gulp-jsmin');
  8. var rename = require('gulp-rename');
  9. gulp.task('scripts', function () {
  10. gulp.src('./js/*.js')
  11. .pipe(jsmin())
  12. .pipe(rename({suffix: '.min'}))
  13. .pipe(gulp.dest('./js/dist/'));
  14. });
  15. gulp.task('scss', function () {
  16. gulp.src('./scss/*.scss')
  17. .pipe(sass().on('error', sass.logError))
  18. .pipe(gulp.dest('./css'));
  19. });
  20. gulp.task('css', function () {
  21. gulp.src('./css/*.css')
  22. //autoprefixer
  23. .pipe(autoprefixer({
  24. browsers: ['last 2 versions'],
  25. cascade: false
  26. }))
  27. .pipe(gulp.dest('./css'))
  28. // cleancss
  29. .pipe(cleancss())
  30. .pipe(rename({ suffix: '.min' }))
  31. .pipe(gulp.dest('./css/dist'));
  32. });
  33. // default gulp task
  34. gulp.task('default', ['scripts', 'scss', 'css'], function() {
  35. gulp.watch('./scss/**/*.scss', ['scss']);
  36. gulp.watch('./css/**/*.css', ['css']);
  37. gulp.watch('./js/**/*.js', ['scripts']);
  38. });