SHARE
TWEET

Untitled

a guest Feb 2nd, 2019 125 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const gulp = require('gulp');
  2. const plumber = require('gulp-plumber');
  3. const sass = require('gulp-sass');
  4. const postcss = require('gulp-postcss');
  5. const autoprefixer = require('autoprefixer');
  6. const sourcemaps = require('gulp-sourcemaps');
  7. const groupmq = require('gulp-group-css-media-queries');
  8. const bs = require('browser-sync');
  9.  
  10. const SASS_SOURCES = [
  11.   './*.scss', // This picks up our style.scss file at the root of the theme
  12.   'css/**/*.scss', // All other Sass files in the /css directory
  13. ];
  14.  
  15. /**
  16.  * Compile Sass files
  17.  */
  18. gulp.task('compile:sass', ['lint:sass'], () =>
  19.   gulp.src(SASS_SOURCES, { base: './' })
  20.     .pipe(plumber()) // Prevent termination on error
  21.     .pipe(sass({
  22.       indentType: 'tab',
  23.       indentWidth: 1,
  24.       outputStyle: 'expanded', // Expanded so that our CSS is readable
  25.     })).on('error', sass.logError)
  26.     .pipe(postcss([
  27.       autoprefixer({
  28.         browsers: ['last 2 versions'],
  29.         cascade: false,
  30.       })
  31.     ]))
  32.     .pipe(groupmq()) // Group media queries!
  33.     .pipe(gulp.dest('.')) // Output compiled files in the same dir as Sass sources
  34.     .pipe(bs.stream())); // Stream to browserSync
  35.  
  36. /**
  37.  * Start up browserSync and watch Sass files for changes
  38.  */
  39. gulp.task('watch:sass', ['compile:sass'], () => {
  40.   bs.init({
  41.     proxy: 'http://localhost/wordpress-installation'
  42.   });
  43.  
  44.   gulp.watch(SASS_SOURCES, ['compile:sass', 'lint:sass']);
  45. });
  46.  
  47. /**
  48.  * Lint Sass
  49.  */
  50. gulp.task('lint:sass', () =>
  51.   gulp.src(SASS_SOURCES)
  52.     .pipe(plumber())
  53.     .pipe(sassLint())
  54.     .pipe(sassLint.format()));
  55.  
  56. /**
  57.  * Default task executed by running `gulp`
  58.  */
  59. gulp.task('default', ['watch:sass']);
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top