Created
December 30, 2014 08:43
-
-
Save limdauto/2d77f4052b3d3752a038 to your computer and use it in GitHub Desktop.
Lim's todojs build
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
'use strict'; | |
var _ = require('lodash'), | |
browserify = require('browserify'), | |
compass = require('gulp-compass'), | |
concat = require('gulp-concat'), | |
conf = require('config'), | |
console = require('console-browserify'), | |
del = require('del'), | |
gulp = require('gulp'), | |
gutil = require('gulp-util'), | |
minifyCss = require('gulp-minify-css'), | |
seq = require('run-sequence'), | |
source = require('vinyl-source-stream'), | |
sprintf = require('sprintf'), | |
streamify = require('gulp-streamify'), | |
uglify = require('gulp-uglify'); | |
// list of apps | |
var apps = ['todo-mithril-mocha']; | |
gulp.task('clean', function(cb) { | |
del([sprintf('%s/css/*.css', conf.DIST), sprintf('%s/js/*.js', conf.DIST)]); | |
}); | |
gulp.task('deploy', ['build'], function() { | |
// nothing here yet | |
// @TODO: separate default task (dev) with deploy by uglify for deploy and add source map | |
}); | |
gulp.task('default', ['build'] ,function() { | |
// nothing here yet, adding source map maybe? | |
}); | |
gulp.task('build', function() { | |
seq('js', 'css'); | |
}); | |
gulp.task('test', ['js:test'], function() {}); | |
/************************************ | |
* JAVASCRIPT TASKS | |
************************************/ | |
function parseModule(name, targetTask) { | |
return require(sprintf('%s/%s/%s', conf.NODE_ROOT, name, conf.TASK_CONF))[targetTask]; | |
} | |
// build tasks | |
gulp.task('js', _.map(apps, function(app) { return sprintf('js:%s', app); }), function() {}); | |
_.forEach(apps, function(app) { | |
gulp.task(sprintf('js:%s', app), parseModule(app, 'build')); | |
}); | |
// test tasks | |
gulp.task('js:test', _.map(apps, function(app) { return sprintf('js:%s:test', app); }), function() {}); | |
_.forEach(apps, function(app) { | |
gulp.task(sprintf('js:%s:test', app), parseModule(app, 'test')); | |
}); | |
/************************************ | |
* CSS TASKS | |
************************************/ | |
gulp.task('css', ['css:lib', 'css:compass'], function() { | |
return gulp.src([ | |
sprintf('css/%s', conf.LIB_CSS), | |
sprintf('css/%s', conf.MAIN_CSS) | |
]) | |
.pipe(concat(conf.MAIN_CSS)) | |
.pipe(minifyCss()) | |
.pipe(gulp.dest(sprintf("%s/css", conf.DIST))); | |
}); | |
gulp.task('css:lib', function() { | |
return gulp.src([ | |
sprintf('%s/normalize.css/normalize.css', conf.BOWER) | |
]) | |
.pipe(concat(conf.LIB_CSS)) | |
.pipe(gulp.dest('css')); | |
}); | |
gulp.task('css:compass', function () { | |
return gulp.src(conf.SASS) | |
.pipe(compass({ | |
css: 'css/', | |
sass: 'css/sass/' | |
})) | |
.pipe(concat(conf.MAIN_CSS)) | |
.pipe(gulp.dest('css')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
config.js will look like this