gulpfile.js 1.0 KB

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