Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var path = require('path'),//standart
- gulp = require('gulp'),//standart
- rename = require('gulp-rename'),
- debug = require('gulp-debug'),
- plumber = require('gulp-plumber'),
- gutil = require('gulp-util'),
- bs = require('browser-sync').create(),
- sass = require('gulp-sass'),
- cache = require('gulp-cached'),
- cleanCSS = require('gulp-clean-css'),
- // sourcemaps = require('gulp-sourcemaps'),
- lec = require('gulp-line-ending-corrector'),
- autoprefixer = require('gulp-autoprefixer');
- // error handler
- var onError = function (err) {
- gutil.beep();
- console.log(err);
- };
- var source = 'systemforex_ru/local/**/sass/*.scss',
- sourceMin = 'systemforex_ru/local/**/css/*.css',
- destination = './systemforex_ru/local/';
- //sass build
- gulp.task('sass', function () {
- return gulp.src([source], {
- dot: true
- })
- .pipe(cache('onlychanged'))
- .pipe(plumber({errorHandler: onError}))
- // .pipe(sourcemaps.init())
- .pipe(sass().on('error', sass.logError))
- // .pipe(sourcemaps.write({includeContent: false}))
- .pipe(autoprefixer({
- browsers: ['last 15 versions'],
- cascade: true
- }))
- .pipe(rename(function (filePath) {
- filePath.dirname = path.join(filePath.dirname, '../css/');
- return filePath;
- }))
- .pipe(lec({verbose:true, eolc: 'CRLF', encoding:'utf8'}))
- .pipe(debug({title: 'wt-monitor:'}))
- .pipe(gulp.dest(destination));
- });
- //minify
- gulp.task('css', function () {
- return gulp.src([sourceMin, '!systemforex_ru/local/**/css/*min.css'], {
- dot: true
- })
- .pipe(cache('onlychanged'))
- .pipe(plumber({errorHandler: onError}))
- .pipe(rename({suffix: '.min'}))
- .pipe(cleanCSS({debug: true}, function (details) {
- console.log(details.name + ': ' + details.stats.originalSize);
- console.log(details.name + ': ' + details.stats.minifiedSize);
- }))
- .pipe(rename(function (filePath) {
- filePath.dirname = path.join(filePath.dirname, '.');
- return filePath;
- }))
- .pipe(lec({verbose:true, eolc: 'CRLF', encoding:'utf8'}))
- .pipe(gulp.dest(destination));
- });
- gulp.task('watch', function () {
- gulp.watch([source], {
- dot: true
- }, ['sass']);
- gulp.watch([sourceMin, '!systemforex_ru/local/**/css/*min.css'], {
- dot: true
- }, ['css']);
- });
- gulp.task('default', ['watch', 'sass', 'css']);
- gulp.task('default', ['watch', 'sass', 'css']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement