gulpfile.js 946 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. var gulp = require('gulp');
  2. var sass = require('gulp-sass');
  3. var cleancss = require('gulp-clean-css');
  4. var csscomb = require('gulp-csscomb');
  5. var rename = require('gulp-rename');
  6. var autoprefixer = require('gulp-autoprefixer');
  7. var sourcemaps = require('gulp-sourcemaps');
  8. // configure the paths
  9. var watch_dir = './scss/**/*.scss';
  10. var src_dir = './scss/*.scss';
  11. var dest_dir = './css-compiled';
  12. var paths = {
  13. source: src_dir
  14. };
  15. gulp.task('watch', function() {
  16. gulp.watch(watch_dir, ['build']);
  17. });
  18. gulp.task('build', function() {
  19. gulp.src(paths.source)
  20. .pipe(sourcemaps.init())
  21. .pipe(sass({outputStyle: 'compact', precision: 10})
  22. .on('error', sass.logError)
  23. )
  24. .pipe(sourcemaps.write())
  25. .pipe(autoprefixer())
  26. .pipe(gulp.dest(dest_dir))
  27. .pipe(csscomb())
  28. .pipe(cleancss())
  29. .pipe(rename({
  30. suffix: '.min'
  31. }))
  32. .pipe(gulp.dest(dest_dir));
  33. });
  34. gulp.task('default', ['build']);