Guest User

Untitled

a guest
Sep 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. 'use strict';
  2.  
  3. var gulp = require('gulp');
  4. var del = require('del');
  5. var sass = require('gulp-sass');
  6. var cleanCSS = require('gulp-clean-css');
  7. var autoprefixer = require('gulp-autoprefixer');
  8. var uglify = require('gulp-uglify');
  9. var htmlmin = require('gulp-htmlmin');
  10. var connect = require('gulp-connect');
  11. var livereload = require('gulp-livereload');
  12.  
  13. livereload({ start: true })
  14.  
  15. var AUTOPREFIXER_BROWSERS = [
  16. 'ie >= 10',
  17. 'ie_mob >= 10',
  18. 'ff >= 30',
  19. 'chrome >= 34',
  20. 'safari >= 7',
  21. 'opera >= 23',
  22. 'ios >= 7',
  23. 'android >= 4.4',
  24. 'bb >= 10'
  25. ];
  26.  
  27. function server () {
  28. connect.server();
  29. }
  30.  
  31. function clearDist () {
  32. return del([
  33. './dist/**/*'
  34. ]);
  35. }
  36.  
  37. function sassCompile () {
  38. return gulp.src('./styles/**/*.sass')
  39. .pipe(sass().on('error', sass.logError))
  40. .pipe(autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
  41. .pipe(cleanCSS({compatibility: 'ie8'}))
  42. .pipe(gulp.dest('./dist'))
  43. .pipe(livereload());
  44. };
  45.  
  46. function cssCompile () {
  47. return gulp.src('./styles/*.css')
  48. .pipe(cleanCSS({compatibility: 'ie8'}))
  49. .pipe(gulp.dest('./dist'))
  50. .pipe(livereload());
  51. }
  52.  
  53. function jsCompile () {
  54. return gulp.src('./js/*.js')
  55. .pipe(uglify())
  56. .pipe(gulp.dest('./dist'))
  57. .pipe(livereload());
  58. }
  59.  
  60. function htmlCompile () {
  61. return gulp.src(['./*.html'])
  62. .pipe(htmlmin({
  63. collapseWhitespace: true,
  64. removeComments: true
  65. }))
  66. .pipe(gulp.dest('./dist'))
  67. .pipe(livereload());
  68. }
  69.  
  70. function watch () {
  71. livereload.listen();
  72. gulp.watch("./styles/*", gulp.series(sassCompile, cssCompile));
  73. gulp.watch("./js/*", gulp.series(jsCompile));
  74. gulp.watch("./*.html", gulp.series(htmlCompile));
  75. }
  76.  
  77. gulp.task("watch", gulp.parallel(watch, server));
  78.  
  79. gulp.task('default', gulp.series(clearDist ,sassCompile, cssCompile, jsCompile, htmlCompile));
Add Comment
Please, Sign In to add comment