gulp config
var gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
pngquant = require('imagemin-pngquant'),
jpegtran = require('imagemin-jpegtran'),
gifsicle = require('imagemin-gifsicle'),
concatCSS = require('gulp-concat-css'),
autoprefixer = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
minifyCss = require('gulp-minify-css'),
sass = require('gulp-sass')
;
//Сжатие картинок
gulp.task('optimize-images', function () {
return gulp.src(['assets/app/images/**/*.jpg', 'assets/app/images/**/*.jpeg', 'assets/app/images/**/*.gif', 'assets/app/images/**/*.png'])
.pipe(imagemin({
progressive: false,
use: [pngquant(), jpegtran(), gifsicle()]
}))
.pipe(gulp.dest('assets/app/images/'));
});
//css
gulp.task('css', function() {
return gulp.src(['assets/css/*.css', 'assets/css/*.css'])
.pipe(concatCSS('bundle.css'))
.pipe(minifyCss())
.pipe(autoprefixer())
.pipe(rename ('bundle.min.css'))
.pipe(gulp.dest('assets/dist'));
});
//Сжатие js
gulp.task('js', function() {
return gulp.src(['assets/app/js/*.js', 'assets/app/js/*.js'])
.pipe(uglify())
.pipe(concat('bundle.all.js'))
.pipe(gulp.dest('assets/dist'));
});
//sass
gulp.task('scss', function(){
return gulp.src('assets/app/scss/*.scss')
.pipe(sass())
.pipe(concatCSS('bundle.css'))
.pipe(minifyCss())
.pipe(rename ('bundle.min.css'))
.pipe(gulp.dest('assets/dist'))
});
gulp.task('watch', function() {
gulp.watch('assets/app/scss/**/*.scss', ['scss']);
gulp.watch('assets/app/js/*.js', ['js']);
});
gulp.task('build', ['clean', 'scss', 'js']);