Skip to content

Instantly share code, notes, and snippets.

@tonyoconnell
Created August 27, 2014 18:52
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 tonyoconnell/529d0dce9eb52826dfcf to your computer and use it in GitHub Desktop.
Save tonyoconnell/529d0dce9eb52826dfcf to your computer and use it in GitHub Desktop.
var gulp = require('gulp'), // Gulp
jade = require('gulp-jade'), // Jade
stylus = require('gulp-stylus'), // Stylus
autoprefixer = require('gulp-autoprefixer'), // Autoprefixer
csso = require('gulp-csso'), // CSSO
imagemin = require('gulp-imagemin'), // Imagemin
concat = require('gulp-concat'), // Concat
cache = require('gulp-cache'); // Cache
browsersync = require('browser-sync'); // Browser-Sync
var dev_path =
{
stylus: ['dev/stylus/*.styl', '!dev/stylus/_*.styl'],
jade: ['dev/jade/*.jade', '!dev/jade/_*.jade'],
js: ['dev/js/**/*.js', '!dev/js/vendor/*.js'],
images: 'dev/img/**/*'
}
var build_path =
{
css: 'build/css/',
html: 'build/',
js: 'build/js/',
images: 'build/img'
}
// Compile Jade
gulp.task('jade', function(){
return gulp.src(dev_path.jade)
.pipe(jade({pretty: true}))
.on('error', console.log)
.pipe(gulp.dest(build_path.html))
.pipe(browsersync.reload({stream: true}))
});
// Compile Stylus
gulp.task('stylus', function(){
return gulp.src(dev_path.stylus)
.pipe(stylus())
.on('error', console.log)
.pipe(autoprefixer())
.pipe(gulp.dest(build_path.css))
.pipe(browsersync.reload({stream: true}))
});
// Minification JavaScript
gulp.task('js', function(){
return gulp.src(dev_path.js)
.pipe(concat('main.js'))
.on('error', console.log)
.pipe(gulp.dest(build_path.js))
.pipe(browsersync.reload({stream: true}))
});
// Minification Images
gulp.task('images', function(){
return gulp.src(dev_path.images)
.pipe(cache(imagemin({ optimizationLevel: 3 })))
.pipe(gulp.dest(build_path.images))
.pipe(browsersync.reload({stream: true}))
});
// Start Browser-Sync server
gulp.task('browsersync-server', function(){
return browsersync.init(null, {server: {baseDir: 'build/'}})
});
//
// WATCH TASK
//
gulp.task('watch', function(){
gulp.watch('dev/jade/*.jade', ['jade']);
gulp.watch('dev/stylus/**/*.styl', ['stylus']);
gulp.watch(dev_path.images, ['images']);
gulp.watch(dev_path.js, ['js']);
});
//
// DEFAULT TASK
//
gulp.task('default', function(){
gulp.src('dev/stylus/vendor/*').pipe(gulp.dest('build/css/'));
gulp.src('dev/js/vendor/*').pipe(gulp.dest('build/js/'));
gulp.src('dev/fonts/*').pipe(gulp.dest('build/fonts/'));
gulp.start('jade', 'stylus', 'images', 'js', 'browsersync-server', 'watch');
});
@tonyoconnell
Copy link
Author

Nice setup... almost exactly the same as mine :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment