Created
May 12, 2017 08:59
-
-
Save SergeyZaigraev/0805e481a0300f4dc2773796c4c15a4c to your computer and use it in GitHub Desktop.
Gulp for project. Необходимый минимум для оптимизации
проекта на битре
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var rename = require("gulp-rename"); | |
var uglify = require('gulp-uglify'); | |
var cleanCSS = require('gulp-clean-css'); | |
var templateName = 'main'; | |
var imagemin = require('gulp-imagemin'); | |
gulp.task('imagemin',function () { | |
return gulp.src([ | |
templateName + '/**/*.{png,gif,jpg,jpeg,svg}', | |
'../../images/**/*.{png,gif,jpg,jpeg,svg}' | |
], {base: './'}) | |
.pipe(imagemin()) | |
.pipe(gulp.dest('./')); | |
}); | |
gulp.task('uglify-js', function () { | |
return gulp.src([ | |
templateName + '/**/*.js', | |
'!' + templateName + '/**/*.min.js', | |
'!' + templateName + '/**/*.map.js' | |
]) | |
.pipe(uglify().on('error', function() { | |
console.log(arguments) | |
})) | |
.pipe(rename(function (path) { | |
path.basename += '.min'; | |
})) | |
.pipe(gulp.dest(templateName + '/')); | |
}); | |
gulp.task('minify-css', function() { | |
return gulp.src([ | |
templateName + '/**/*.css', | |
'!' + templateName + '/**/*.min.css', | |
'!' + templateName + '/**/*.map.css' | |
]) | |
.pipe(cleanCSS({ | |
compatibility: 'ie8', | |
advanced: false | |
})) | |
.pipe(rename(function (path) { | |
path.basename += '.min'; | |
})) | |
.pipe(gulp.dest(templateName + '/')); | |
}); | |
gulp.task('default', ['uglify-js', 'minify-css']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment