SHARE
TWEET

Untitled

a guest Jan 12th, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var path = require('path'),//standart
  2.     gulp = require('gulp'),//standart
  3.     rename = require('gulp-rename'),
  4.     debug = require('gulp-debug'),
  5.     plumber = require('gulp-plumber'),
  6.     gutil = require('gulp-util'),
  7.     bs = require('browser-sync').create(),
  8.     sass = require('gulp-sass'),
  9.     cache = require('gulp-cached'),
  10.     cleanCSS = require('gulp-clean-css'),
  11. // sourcemaps = require('gulp-sourcemaps'),
  12.     lec =  require('gulp-line-ending-corrector'),
  13.     autoprefixer = require('gulp-autoprefixer');
  14. // error handler
  15. var onError = function (err) {
  16.     gutil.beep();
  17.     console.log(err);
  18. };
  19. var source = 'systemforex_ru/local/**/sass/*.scss',
  20.     sourceMin = 'systemforex_ru/local/**/css/*.css',
  21.     destination = './systemforex_ru/local/';
  22. //sass build
  23. gulp.task('sass', function () {
  24.     return gulp.src([source], {
  25.         dot: true
  26.     })
  27.         .pipe(cache('onlychanged'))
  28.         .pipe(plumber({errorHandler: onError}))
  29.         // .pipe(sourcemaps.init())
  30.         .pipe(sass().on('error', sass.logError))
  31.         // .pipe(sourcemaps.write({includeContent: false}))
  32.         .pipe(autoprefixer({
  33.             browsers: ['last 15 versions'],
  34.             cascade: true
  35.  
  36.         }))
  37.         .pipe(rename(function (filePath) {
  38.             filePath.dirname = path.join(filePath.dirname, '../css/');
  39.             return filePath;
  40.         }))
  41.         .pipe(lec({verbose:true, eolc: 'CRLF', encoding:'utf8'}))
  42.         .pipe(debug({title: 'wt-monitor:'}))
  43.         .pipe(gulp.dest(destination));
  44. });
  45. //minify
  46. gulp.task('css', function () {
  47.     return gulp.src([sourceMin, '!systemforex_ru/local/**/css/*min.css'], {
  48.         dot: true
  49.     })
  50.         .pipe(cache('onlychanged'))
  51.         .pipe(plumber({errorHandler: onError}))
  52.         .pipe(rename({suffix: '.min'}))
  53.         .pipe(cleanCSS({debug: true}, function (details) {
  54.             console.log(details.name + ': ' + details.stats.originalSize);
  55.             console.log(details.name + ': ' + details.stats.minifiedSize);
  56.         }))
  57.         .pipe(rename(function (filePath) {
  58.             filePath.dirname = path.join(filePath.dirname, '.');
  59.             return filePath;
  60.         }))
  61.         .pipe(lec({verbose:true, eolc: 'CRLF', encoding:'utf8'}))
  62.         .pipe(gulp.dest(destination));
  63. });
  64. gulp.task('watch', function () {
  65.     gulp.watch([source], {
  66.         dot: true
  67.  
  68.     }, ['sass']);
  69.  
  70.     gulp.watch([sourceMin, '!systemforex_ru/local/**/css/*min.css'], {
  71.         dot: true
  72.     }, ['css']);
  73. });
  74.  
  75. gulp.task('default', ['watch', 'sass', 'css']);
  76.  
  77.  
  78. gulp.task('default', ['watch', 'sass', 'css']);
RAW Paste Data
Top