Guest User

Untitled

a guest
Jan 24th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import gulp from 'gulp';
  2. import postcss from 'gulp-postcss';
  3. import sourcemaps from 'gulp-sourcemaps';
  4. import cssnano from 'cssnano';
  5. import autoprefixer from 'autoprefixer';
  6. import lost from 'lost';
  7. import {create as bsCreate} from 'browser-sync';
  8. const browserSync = bsCreate();
  9.  
  10. const dirs = {
  11. src: 'src',
  12. dest: 'dist',
  13. };
  14.  
  15. const cssPaths = {
  16. srcFiles: `${dirs.src}/css/*.css`,
  17. destDir: `${dirs.dest}/css`,
  18. }
  19.  
  20. gulp.task('css', () => {
  21. return gulp.src(cssPaths.srcFiles)
  22. .pipe(sourcemaps.init())
  23. .pipe(postcss([
  24. lost(),
  25. autoprefixer(),
  26. cssnano(),
  27. ]))
  28. .pipe(sourcemaps.write('.'))
  29. .pipe(gulp.dest(cssPaths.destDir));
  30. });
  31.  
  32. gulp.task('browser-sync', () => {
  33. browserSync.init({
  34. server: {
  35. baseDir: "./"
  36. }
  37. });
  38. });
  39.  
  40. gulp.task('watch', () => {
  41. gulp.watch(cssPaths.srcFiles, ['css', browserSync.reload]);
  42. gulp.watch("*.html", browserSync.reload);
  43. });
  44.  
  45. gulp.task('default', ['css', 'browser-sync', 'watch']);
Add Comment
Please, Sign In to add comment