Created
July 26, 2014 10:38
-
-
Save mkusher/8f479b86da644de9b299 to your computer and use it in GitHub Desktop.
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
/** | |
* This file is part of package | |
* | |
* (c) Aleh Kashnikau <[email protected]> | |
* | |
* Created: 7/25/14. | |
*/ | |
var gulp = require('gulp'); | |
var concat = require('gulp-concat'); | |
var uglify = require('gulp-uglify'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var minify = require('gulp-minify-css'); | |
var _ = require('underscore'); | |
var bower_path = 'web/bower_components/'; | |
var vendor = { | |
"jquery": { | |
"js": ['jquery/dist/jquery.min.js'] | |
}, | |
"bootstrap": { | |
"css": [ | |
'bootstrap/dist/css/bootstrap.min.css', | |
'bootstrap/dist/css/bootstrap-theme.min.css' | |
], | |
"js": [ | |
'bootstrap/dist/js/bootstrap.min.js', | |
] | |
}, | |
"fontawesome": { | |
"css": ['fontawesome/css/font-awesome.min.css'], | |
"fonts": ['fontawesome/fonts/*'] | |
}, | |
"chosen": { | |
"js": ['chosen/chosen.jquery.js'], | |
"css": ['chosen/chosen.min.css'] | |
}, | |
"timeline": { | |
"js": ['chosen/chosen.jquery.js'], | |
"css": ['chosen/chosen.min.css'] | |
} | |
}; | |
var angular = { | |
js: [ | |
bower_path + 'angular/angular.min.js', | |
bower_path + 'angular/ui-bootstrap.min.js', | |
bower_path + 'angular/ui-bootstrap-tpls.min.js' | |
] | |
}; | |
var app = [ | |
'web/js/app/controllers/*', | |
'web/js/app/services/*', | |
'web/js/app/*.js' | |
]; | |
var styles = [ | |
'web/css/main.css' | |
]; | |
var vendorPaths = { | |
js: [], | |
css: [], | |
fonts: [] | |
}; | |
_.map(vendor, function(path){ | |
_.map(vendorPaths, function(value, key){ | |
if(path.hasOwnProperty(key)) | |
vendorPaths[key] = _.union(value, path[key]); | |
}); | |
}); | |
_.map(vendorPaths, function(sources, key){ | |
_.each(sources, function(path, index){ | |
sources[index] = bower_path + path; | |
}); | |
vendorPaths[key] = sources; | |
}); | |
gulp.task('vendor', function(){ | |
gulp.src(vendorPaths.js) | |
.pipe(uglify()) | |
.pipe(concat('vendor.min.js')) | |
.pipe(gulp.dest('web/js')); | |
gulp.src(vendorPaths.css) | |
.pipe(minify()) | |
.pipe(concat('vendor.min.css')) | |
.pipe(gulp.dest('web/css')); | |
gulp.src(vendorPaths.fonts) | |
.pipe(gulp.dest('web/fonts')); | |
}); | |
gulp.task('angular', function(){ | |
gulp.src(angular.js) | |
.pipe(uglify()) | |
.pipe(concat('angular.min.js')) | |
.pipe(gulp.dest('web/js')); | |
}); | |
gulp.task('styles', function(){ | |
return gulp.src(styles) | |
.pipe(minify()) | |
.pipe(concat('main.min.css')) | |
.pipe(gulp.dest('web/css')); | |
}); | |
gulp.task('app', function(){ | |
return gulp.src(app) | |
.pipe(uglify()) | |
.pipe(concat('app.min.js')) | |
.pipe(gulp.dest('web/js')); | |
}); | |
gulp.task('default', ['vendor', 'angular', 'styles', 'app'], function(){ | |
gulp.watch(app, ['app']); | |
gulp.watch(styles, ['styles']) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment