aboutsummaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js72
1 files changed, 51 insertions, 21 deletions
diff --git a/gulpfile.js b/gulpfile.js
index a3c28e1..b22b542 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -2,6 +2,7 @@
var gulp = require('gulp'),
changed = require('gulp-changed'),
+ coffee = require('gulp-coffee'),
concat = require('gulp-concat'),
debug = require('gulp-debug'),
foreach = require('gulp-foreach'),
@@ -21,7 +22,7 @@ var gulp = require('gulp'),
merge = require('merge-stream'),
del = require('del');
-var bootswatch_theme = 'superhero';
+var bootswatch_theme = 'lumen';
var production = false;
@@ -30,13 +31,18 @@ gulp.task('default', [], function() {
});
gulp.task('all', [], function() {
- gulp.start('fonts', 'styles', 'scripts', 'images', 'jade');
+ gulp.start('fonts', 'styles', 'scripts', 'images', 'jade', '3rd-party-styles', '3rd-party-scripts');
});
gulp.task('rebuild', ['clean'], function() {
gulp.start('all');
});
+gulp.task('production', ['clean'], function(){
+ production = true;
+ gulp.start('all');
+});
+
gulp.task('clean', function(cb) {
del(['./build/assets/css', './build/assets/js', './build/assets/less', './build/assets/img', './build/assets/fonts', './build/*.html'], cb)
});
@@ -55,7 +61,7 @@ gulp.task('fonts', function() {
.pipe(gulp.dest(dst));
});
-gulp.task('styles', function() {
+gulp.task('3rd-party-styles', function() {
var baseContent =
'@import "./bower_components/bootstrap/less/bootstrap.less";' +
@@ -77,8 +83,7 @@ gulp.task('styles', function() {
var fileList = [
'./bower_components/bootswatch/' + bootswatch_theme + '/bootswatch.less',
- './bower_components/fontawesome/css/font-awesome.css',
- './src/css/style.less'
+ './bower_components/fontawesome/css/font-awesome.css'
];
var dst = './build/assets/css';
@@ -87,7 +92,7 @@ gulp.task('styles', function() {
return gulp.src(fileList)
.pipe(changed(dst, {extension: '.css', destination: function(file){
if (isBootswatchFile(file)) {
- return 'bootswatch.css';
+ return bootswatch_dst;
} else {
return file;
}
@@ -106,17 +111,34 @@ gulp.task('styles', function() {
// http://stackoverflow.com/questions/21719833/gulp-how-to-add-src-files-in-the-middle-of-a-pipe
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md
- return merge(stream, gulp.src(['./build/assets/css/font-awesome.css', './build/assets/css/main.css']))
- .pipe(concat('bootswatch.css'))
- .pipe(gulp.dest(dst))
- .pipe(rename({suffix: '.min'}))
- .pipe(minifycss());
+ return merge(stream, gulp.src(['./build/assets/css/font-awesome.css']))
+ .pipe(concat(bootswatch_dst))
})))
- .pipe(minifycss())
+ .pipe(minifycss({processImport: false}))
.pipe(gulp.dest(dst));
});
-gulp.task('scripts', function(){
+gulp.task('styles', function() {
+
+ var sources = [
+ './src/css/forms.less',
+ './src/css/general.less',
+ './src/css/profile.less',
+ './src/css/bootswatch-' + bootswatch_theme + '.less'
+ ];
+
+ var dst = './build/assets/css';
+ var dst_filename = 'style.css';
+
+ return gulp.src(sources)
+ .pipe(changed(dst, {destination: dst_filename}))
+ .pipe(less())
+ .pipe(concat(dst_filename))
+ .pipe(gulpif(production, minifycss()))
+ .pipe(gulp.dest(dst));
+});
+
+gulp.task('3rd-party-scripts', function(){
var fileList = [
'./bower_components/jquery/dist/jquery.min.js',
'./bower_components/bootstrap/dist/js/bootstrap.min.js',
@@ -125,19 +147,27 @@ gulp.task('scripts', function(){
var dst = './build/assets/js';
- gulp.src(fileList)
+ return gulp.src(fileList)
.pipe(changed(dst, {destination: 'script.js'}))
.pipe(concat('script.js'))
.pipe(stripdebug())
.pipe(uglify())
.pipe(gulp.dest(dst));
+});
- var src = './src/js/*.js';
+gulp.task('scripts', function(){
+ var src = [
+ './src/js/*.js',
+ './src/js/*.coffee'
+ ]
+ ;
+ var dst = './build/assets/js';
- gulp.src(src)
- .pipe(changed(dst))
+ return gulp.src(src)
+ .pipe(changed(dst, { extension: 'js' }))
+ .pipe(gulpif(/\.coffee$/, coffee()))
.pipe(gulpif(production, stripdebug()))
- .pipe(uglify())
+ .pipe(gulpif(production, uglify()))
.pipe(gulp.dest(dst));
});
@@ -145,7 +175,7 @@ gulp.task('images', function(){
var src = './src/img/**/*',
dst = './build/img';
- gulp.src(src)
+ return gulp.src(src)
.pipe(changed(dst))
.pipe(imagemin())
.pipe(gulp.dest(dst));
@@ -155,10 +185,10 @@ gulp.task('jade', function(){
var src = './src/*.jade',
dst = './build';
- gulp.src(src)
+ return gulp.src(src)
.pipe(changed(dst, {extension: 'html'}))
.pipe(jade())
- .pipe(minifyhtml())
+ .pipe(gulpif(production, minifyhtml()))
.pipe(gulp.dest(dst));
});