SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2.  
  3. const gulp = require('gulp');
  4. const sass = require('gulp-sass');
  5. const autoPrefixer = require('gulp-autoprefixer');
  6. const cssComb = require('gulp-csscomb');
  7. const cssClean = require('gulp-clean-css');
  8. const plumber = require('gulp-plumber');
  9. const uglify = require('gulp-uglify');
  10. const rename = require('gulp-rename');
  11. const liveReload = require('gulp-livereload');
  12. const del = require('del');
  13.  
  14. const path = {
  15.     dev: {
  16.         css: 'development/style.sass',
  17.         js: 'development/scripts/**/*.js'
  18.     },
  19.     prod: {
  20.         css: 'production/styles/',
  21.         js: 'production/scripts/'
  22.     },
  23.     watch: {
  24.         css: [
  25.             'development/styles/blocks/*.sass',
  26.             'development/styles/common/*.sass',
  27.             'development/styles/helpers/*.sass'
  28.         ],
  29.         js: 'development/scripts/**/*.js'
  30.     }
  31. };
  32.  
  33. // LiveReload
  34. function lReload() {
  35.     liveReload.listen();
  36. }
  37.  
  38. // Clean dir
  39. function clean() {
  40.     return del([
  41.         'production/**',
  42.         '!production',
  43.         '!production/images/**',
  44.         '!production/vendor/**',
  45.         '!production/fonts/**'
  46.     ]);
  47. }
  48.  
  49. // Styles
  50. function styles() {
  51.     return gulp
  52.         .src(path.dev.css)
  53.         .pipe(plumber())
  54.         .pipe(sass())
  55.         .pipe(autoPrefixer({browsers: ['last 2 versions'], cascade: false}))
  56.         .pipe(cssComb())
  57.         .pipe(cssClean())
  58.         .pipe(rename({suffix: '.min'}))
  59.         .pipe(gulp.dest(path.prod.css))
  60.         .pipe(liveReload());
  61. }
  62.  
  63. // Scripts
  64. function scripts() {
  65.     return gulp.src(path.dev.js)
  66.         .pipe(plumber())
  67.         .pipe(uglify())
  68.         .pipe(rename({suffix: '.min'}))
  69.         .pipe(gulp.dest(path.prod.js))
  70.         .pipe(liveReload());
  71. }
  72.  
  73. // Watch files
  74. function watchFiles() {
  75.     gulp.watch(path.watch.css, styles);
  76.     gulp.watch(path.watch.js, scripts);
  77. }
  78.  
  79. // Tasks
  80. exports.styles = gulp.series(styles);
  81. exports.scripts = gulp.series(scripts);
  82. exports.clean = gulp.series(clean);
  83.  
  84. // Build
  85. exports.build = gulp.series(clean, gulp.parallel(styles, scripts));
  86.  
  87. // Watch
  88. exports.watch = gulp.parallel(watchFiles, lReload);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top