fonts.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import gulp from 'gulp';
  2. import sass from 'gulp-sass';
  3. import postcss from 'gulp-postcss';
  4. import size from 'gulp-size';
  5. import config from '../config';
  6. import minify from 'gulp-clean-css';
  7. import rename from 'gulp-rename';
  8. import gulpif from 'gulp-if';
  9. import notify from 'gulp-notify';
  10. import del from 'del';
  11. import notifier from 'node-notifier';
  12. // FONTS
  13. // ------------------
  14. gulp.task('fonts', () => {
  15. return gulp
  16. .src(`${config.fonts.source}/*/*.scss`)
  17. .pipe(
  18. sass({
  19. precision: 10, // https://github.com/sass/sass/issues/1122
  20. includePaths: config.styles.include,
  21. })
  22. )
  23. .pipe(postcss())
  24. .pipe(size({gzip: true, showFiles: true}))
  25. .pipe(gulp.dest(`${config.fonts.build}`))
  26. .pipe(minify())
  27. .pipe(rename({
  28. extname: '.min.css'
  29. }))
  30. .pipe(size({gzip: true, showFiles: true}))
  31. .pipe(gulp.dest(`${config.fonts.build}`))
  32. .pipe(
  33. gulpif(
  34. config.enable.notify,
  35. notify({
  36. title: config.notify.title,
  37. message: 'Fonts task complete',
  38. onLast: true,
  39. })
  40. )
  41. );
  42. });
  43. // Clean fonts files
  44. gulp.task('clean:fonts', (done) => {
  45. return del([`${config.fonts.build}/**/*.css`]).then(() => {
  46. if (config.enable.notify) {
  47. notifier.notify({
  48. title: config.notify.title,
  49. message: 'Clean fonts task complete',
  50. });
  51. }
  52. done();
  53. });
  54. });