Skip to content

Instantly share code, notes, and snippets.

@simevidas
Created December 28, 2014 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simevidas/14386facb6b26596324a to your computer and use it in GitHub Desktop.
Save simevidas/14386facb6b26596324a to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
// server
var server = require('gulp-express');
var livereload = require('gulp-livereload');
// css
var stylus = require('gulp-stylus');
var autoprefixer = require('gulp-autoprefixer');
var minify = require('gulp-minify-css');
// js
var browserify = require('gulp-browserify');
// the following two are needed for source maps?
//var buffer = require('vinyl-buffer');
//var maps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
// lint
var jshint = require('gulp-jshint');
var cache = require('gulp-cached');
// images
var imagemin = require('gulp-imagemin');
// picker
var concat = require('gulp-concat');
gulp.task('server', function () {
server.run(); // IMPORTANT: I’ve eited gulp-express’s index.js to set port to 35730!!
livereload.listen();
gulp.watch('source/styl/*.styl', ['build-css']);
gulp.watch('source/js/index/*.js', ['build-js']);
gulp.watch(['app.js', 'modules/*.js', 'routes/*.js'], [server.run]);
gulp.watch(['source/js/index/*.js', 'app.js', 'modules/*.js', 'routes/*.js', 'gulpfile.js'], ['lint-js']);
});
gulp.task('build-css', function () {
return gulp.src('source/styl/*.styl')
.pipe(stylus({ compress: false, 'include css': true }))
.pipe(autoprefixer())
.pipe(minify())
.pipe(gulp.dest('public/css/'))
.pipe(livereload());
});
gulp.task('build-js', function () {
return gulp.src('source/js/index/page.js')
.pipe(browserify()) // { debug: true } enables source maps?
.pipe(rename('bundle.js'))
//.pipe(buffer())
.pipe(gulp.dest('public/js/'))
//.pipe(maps.init({ loadMaps: true }))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
//.pipe(maps.write('./'))
.pipe(gulp.dest('public/js/'))
.pipe(livereload());
});
gulp.task('lint-js', function () {
return gulp.src(['source/js/index/*.js', 'app.js', 'modules/*.js', 'routes/*.js', 'gulpfile.js'])
.pipe(cache('linting'))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('compress-images', function () {
return gulp.src('source/img/**/*')
.pipe(imagemin())
.pipe(gulp.dest('public/img/'));
});
gulp.task('picker-js', function () {
return gulp.src(['bower_components/pickadate/lib/compressed/picker.js', 'bower_components/pickadate/lib/compressed/picker.date.js'])
.pipe(concat('picker.min.js'))
.pipe(gulp.dest('public/js/ext/'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment