You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

157 lines
4.4 KiB

var gulp = require('gulp'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require("gulp-rename"),
autoprefixer = require('gulp-autoprefixer'),
cssmin = require('gulp-cssmin'),
//preen = require('preen'),
//bower = require('gulp-bower'),
//gutil = require('gulp-util'),
imageop = require('gulp-image-optimization'),
less = require('gulp-less'),
livereload = require('gulp-livereload'),
sourcemaps = require('gulp-sourcemaps'),
newer = require('gulp-newer');
/**
* less convertation
*/
gulp.task('process-less', function () {
return gulp.src('less/main.less')
.pipe(sourcemaps.init())
.pipe(less().on('error', function(err) {
console.log(err);
}))
//.pipe(autoprefixer({
// browsers:['> 1%', 'Opera > 11', 'Explorer >= 8', 'Firefox >20', 'Chrome > 20']
//}))
.pipe(autoprefixer({
browsers:['> 1%', 'Opera > 11', 'Explorer >= 8', 'Firefox >20', 'Chrome > 20']
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('css'));
});
/**
* concatenate all js used lib files in one vendor.js files and minimized it
*/
gulp.task('make-vendor-js', function () {
return gulp.src([
'bower_components/jquery/jquery.js',
'bower_components/bootstrap/dist/js/bootstrap.js',
'bower_components/superscrollorama/js/greensock/TweenMax.min.js',
'bower_components/superscrollorama/js/jquery.superscrollorama.js'
])
.pipe(concat('vendor.js'))
.pipe(gulp.dest('js'))
.pipe(uglify())
.pipe(rename('vendor.min.js'))
.pipe(gulp.dest('js'))
});
/**
* concatenate all used css lib files in one vendor.css files and minimized it
*/
gulp.task('make-vendor-css', function () {
return gulp.src([
'bower_components/normalize.css/normalize.css',
'bower_components/html5-boilerplate/src/css/main.css',
'bower_components/bootstrap/dist/css/bootstrap.css',
'bower_components/bootstrap/dist/css/bootstrap-theme.css'
])
.pipe(concat('vendor.css'))
.pipe(gulp.dest('css'))
.pipe(cssmin())
.pipe(rename('vendor.min.css'))
.pipe(gulp.dest('css'))
});
gulp.task('main-css',["process-less"], function () {
return gulp.src('css/main.css')
.pipe(livereload());
});
/**
* images optimization
*/
gulp.task('minfy-images', function(cb) {
gulp.src(['img/**/*.png','img/**/*.jpg', 'img/**/*.gif']).pipe(imageop({
optimizationLevel: 5,
progressive: true,
interlaced: true
})).pipe(gulp.dest('img')).on('end', cb).on('error', cb);
});
gulp.task('minfy-png', function(cb) {
gulp.src('img/**/*.png').pipe(imageop({
optimizationLevel: 7
})).pipe(gulp.dest('img')).on('end', cb).on('error', cb);
});
//gulp.task('minify-modules', function () {
// return gulp.src('frontend/web/js/*.js')
// .pipe(newer('frontend/web/min/js'))
// .pipe(uglify())
// .pipe(rename({extname: ".min.js"}))
// .pipe(gulp.dest('frontend/web/min/js'))
//
//});
//gulp.task('production',['make-vendor-js','make-vendor-css','main-css','minify-modules']);
gulp.task('reload', function () {
livereload.reload();
});
//
//gulp.task('watch-js', function () {
// livereload.reload();
// gulp.watch("frontend/web/js/*.js", ["minify-modules"]);
//});
gulp.task('watch-all', function () {
livereload.listen();
gulp.watch("less/main.less", ["main-css"]);
//gulp.watch("frontend/web/js/*.js", ["minify-modules","reload"]);
gulp.watch("*.html", ["reload"]);
});
//gulp.task('watch-workflow', function () {
// gulp.watch(["static_client/css/main.css","static_client/js/_modules/*.js"], ["main-css","minify-modules"]);
//});
//Project maintenance
/**
* update all vendor libs in project
* lib are downloaded with bower, cleaned and copied to lib/ folder
* requires git being installed on server or in the PATH
*/
//gulp.task('update-vendor',['bower-preen','bower-to-project'], function(cb) {
// return gutil.log('libs updated!');
//});
// BOWER MANIPULATIONS
/**
* get vendor libs folders from bower folder and copy to project structure
*/
//gulp.task('bower-to-project', function(cb) {
// return gulp.src('vendor/bower/**/*')
// .pipe(gulp.dest('frontend/web/lib/'));
//});
/**
* update vendor libs installed by bower
* requires git being installed or in the PATH
*/
//gulp.task('bower-update', function(cb) {
// bower({ cmd: 'update'});
//});
/**
* clean unnecessary files from vendor libs installed by bower.js
*/
//gulp.task('bower-preen', function(cb) {
// preen.preen({}, cb);
//});
gulp.task('default', ['watch-all'], function() {
// place code for your default task here
});