gulpfile.js 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. function watch() {
  16. return gulp.watch(watch_dir, build);
  17. }
  18. function build() {
  19. return gulp.src(paths.source)
  20. .pipe(sourcemaps.init())
  21. .pipe(sass({
  22. outputStyle: 'compact',
  23. precision: 10
  24. }).on('error', sass.logError)
  25. )
  26. .pipe(sourcemaps.write())
  27. .pipe(autoprefixer())
  28. .pipe(gulp.dest(dest_dir))
  29. .pipe(csscomb())
  30. .pipe(cleancss())
  31. .pipe(rename({
  32. suffix: '.min'
  33. }))
  34. .pipe(gulp.dest(dest_dir));
  35. }
  36. exports.watch = watch;
  37. exports.build = build;
  38. exports.default = build;