diff --git a/gulp/build.coffee b/gulp/build.coffee new file mode 100644 index 00000000..99d54b39 --- /dev/null +++ b/gulp/build.coffee @@ -0,0 +1,4 @@ +g = require 'gulp' + +g.task 'build', -> + g.start 'clean', 'styles', 'scripts', 'fonts' diff --git a/gulp/clean.coffee b/gulp/clean.coffee new file mode 100644 index 00000000..084dc99b --- /dev/null +++ b/gulp/clean.coffee @@ -0,0 +1,9 @@ +g = require 'gulp' + +g.task 'clean', -> + g.d.sync 'source/assets/css' + g.d.sync 'source/assets/fonts' + g.d.sync 'source/assets/js' + g.d.sync 'output_*/assets/css' + g.d.sync 'output_*/assets/fonts' + g.d.sync 'output_*/assets/js' diff --git a/gulp/default.coffee b/gulp/default.coffee new file mode 100644 index 00000000..0e10d626 --- /dev/null +++ b/gulp/default.coffee @@ -0,0 +1,4 @@ +g = require 'gulp' + +g.task 'default', -> + g.start 'build', 'watch' diff --git a/gulp/fonts.coffee b/gulp/fonts.coffee new file mode 100644 index 00000000..3c5cc530 --- /dev/null +++ b/gulp/fonts.coffee @@ -0,0 +1,4 @@ +g = require 'gulp' + +g.task 'fonts', -> + g.copy('./vendor/bower/font-awesome/fonts/*', './source/assets/fonts') diff --git a/gulp/images.coffee b/gulp/images.coffee new file mode 100644 index 00000000..950051d0 --- /dev/null +++ b/gulp/images.coffee @@ -0,0 +1,6 @@ +g = require 'gulp' + +g.task 'images', -> + g.src 'source/assets/images/*' + .pipe g.p.imagemin() + .pipe g.dest 'source/assets/images' diff --git a/gulp/minify-prod-html.coffee b/gulp/minify-prod-html.coffee new file mode 100644 index 00000000..3d00f61a --- /dev/null +++ b/gulp/minify-prod-html.coffee @@ -0,0 +1,6 @@ +g = require 'gulp' + +g.task 'minify-prod-html', -> + g.src 'output_prod/**/*.html' + .pipe g.p.htmlmin({ collapseWhitespace: true }) + .pipe g.dest 'output_prod' diff --git a/gulp/scripts.coffee b/gulp/scripts.coffee new file mode 100644 index 00000000..b35ac2dc --- /dev/null +++ b/gulp/scripts.coffee @@ -0,0 +1,10 @@ +g = require 'gulp' + +g.task 'scripts', => + g.src ['vendor/bower/jquery/dist/jquery.js', 'vendor/bower/bootstrap-sass/assets/javascripts/bootstrap.js'] + .pipe g.p.plumber() + .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init() + .pipe g.p.concat 'all.js' + .pipe g.p.if g.config.production, g.p.uglify() + .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.') + .pipe g.dest 'source/assets/js' diff --git a/gulp/styles.coffee b/gulp/styles.coffee new file mode 100644 index 00000000..283d373e --- /dev/null +++ b/gulp/styles.coffee @@ -0,0 +1,11 @@ +g = require 'gulp' + +g.task 'styles', -> + g.src ['vendor/bower/font-awesome/css/font-awesome.css', 'sass/styles.scss'] + .pipe g.p.plumber() + .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init() + .pipe g.p.sass() + .pipe g.p.concat 'all.css' + .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.') + .pipe g.dest 'source/assets/css' + .pipe g.p.if g.config.livereload, g.p.livereload() diff --git a/gulp/watch.coffee b/gulp/watch.coffee new file mode 100644 index 00000000..30f1cca5 --- /dev/null +++ b/gulp/watch.coffee @@ -0,0 +1,5 @@ +g = require 'gulp' + +g.task 'watch', -> + g.p.livereload.listen() + g.watch 'sass/**/*.scss', ['styles'] diff --git a/gulpfile.coffee b/gulpfile.coffee new file mode 100644 index 00000000..bdbce1e4 --- /dev/null +++ b/gulpfile.coffee @@ -0,0 +1,17 @@ +g = require('gulp') +g.p = require('gulp-load-plugins')() +g.d = require('del') + +g.config = + bowerDir: 'vendor/bower', + assetsDir: './source/assets', + sassPattern: './sass/**/*.scss', + production: !!g.p.util.env.production, + sourceMaps: !g.p.util.env.production, + liveReload: !g.p.util.env.production + +g.copy = (srcFiles, outputDir) -> + g.src(srcFiles) + .pipe g.dest(outputDir) + +require('fs').readdirSync('./gulp').forEach (task) -> require "./gulp/#{task}" diff --git a/gulpfile.js b/gulpfile.js index b2c620fa..c7f2b8b8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,92 +1,2 @@ -'use strict'; - -var gulp = require('gulp'), - plugins = require('gulp-load-plugins')(), - del = require('del'); - -var config = { - bowerDir: 'vendor/bower', - assetsDir: './source/assets', - sassPattern: './sass/**/*.scss', - production: !!plugins.util.env.production, - sourceMaps: !plugins.util.env.production, - liveReload: !plugins.util.env.production -}; - -var app = {}; - -app.addStyle = function(paths, filename) { - gulp.src(paths) - .pipe(plugins.plumber()) - .pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.init())) - .pipe(plugins.sass()) - .pipe(plugins.concat(filename)) - .pipe(config.production ? plugins.minifyCss() : plugins.util.noop()) - .pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.write('.'))) - .pipe(gulp.dest(config.assetsDir + '/css')) - .pipe(plugins.if(config.liveReload, plugins.livereload())); -}; - -app.copy = function(srcFiles, outputDir) { - gulp.src(srcFiles) - .pipe(gulp.dest(outputDir)); -}; - -app.addScript = function(paths, filename) { - gulp.src(paths) - .pipe(plugins.plumber()) - .pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.init())) - .pipe(plugins.concat(filename)) - .pipe(config.production ? plugins.uglify() : plugins.util.noop()) - .pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.write('.'))) - .pipe(gulp.dest(config.assetsDir + '/js')) -} - -gulp.task('fonts', function () { - // Copy fonts from bower_components into source/asset/fonts. - app.copy(config.bowerDir + '/font-awesome/fonts/*', config.assetsDir + '/fonts'); -}); - -gulp.task('styles', function () { - app.addStyle([ - config.bowerDir + '/font-awesome/css/font-awesome.css', - './sass/styles.scss' - ], 'all.css'); -}); - -gulp.task('scripts', function () { - app.addScript([ - config.bowerDir + '/jquery/dist/jquery.js', - config.bowerDir + '/bootstrap-sass/assets/javascripts/bootstrap.js' - ], 'all.js'); -}); - -gulp.task('images', function () { - // Minify images. - gulp.src(config.imagesDir + '/*') - .pipe(plugins.imagemin()) - .pipe(gulp.dest(config.imagesDir)); -}); - -gulp.task('watch', function () { - plugins.livereload.listen(); - gulp.watch(config.sassPattern, ['styles']); -}); - -gulp.task('clean', function () { - del.sync(config.assetsDir + '/css'); - del.sync(config.assetsDir + '/fonts'); - del.sync(config.assetsDir + '/js'); - del.sync('./output_*/assets/css/*'); - del.sync('./output_*/assets/fonts/*'); -}); - -gulp.task('minify-prod-html', function() { - gulp.src('output_prod/**/*.html') - .pipe(plugins.htmlmin({ collapseWhitespace: true })) - .pipe(gulp.dest('output_prod')); -}); - -gulp.task('build', ['clean', 'styles', 'scripts', 'fonts']); - -gulp.task('default', ['build', 'watch']); +require('coffee-script/register'); +require('./gulpfile.coffee'); diff --git a/package.json b/package.json index 572d6699..f5db32e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "devDependencies": { "bower": "^1.7.7", + "coffee-script": "^1.10.0", "del": "^2.2.0", "gulp": "^3.9.0", "gulp-concat": "^2.6.0", diff --git a/sass/styles.scss b/sass/styles.scss index 301c2b4a..69b88e1e 100644 --- a/sass/styles.scss +++ b/sass/styles.scss @@ -1,4 +1,3 @@ - @import '_variables'; @import '../vendor/bower/compass-breakpoint/stylesheets/breakpoint';