Skip to content

Instantly share code, notes, and snippets.

@langolf
Last active August 29, 2015 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save langolf/8691201 to your computer and use it in GitHub Desktop.
Save langolf/8691201 to your computer and use it in GitHub Desktop.
Simple gulpfile
var gulp = require('gulp'),
jade = require('gulp-jade'),
stylus = require('gulp-stylus'),
autoprefixer = require('gulp-autoprefixer'),
csso = require('gulp-csso'),
imagemin = require('gulp-imagemin'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
browserSync = require('browser-sync'),
clean = require('gulp-clean'),
rename = require('gulp-rename'),
util = require('gulp-util');
require('gulp-grunt')(gulp, {
prexif: '',
verbose: true
});
// Generate sprite.png
gulp.task('sprite', function(){
gulp.start('grunt-sprites');
});
// Stylus
gulp.task('stylus', function(){
gulp.src('./app/styl/style.styl')
.pipe(stylus()).on('error', console.log)
.pipe(gulp.dest('./public/css'));
});
// Jade
gulp.task('jade', function(){
gulp.src(['./app/views/*.jade', '!./app/views/_*.jade'])
.pipe(jade({
pretty: false
}))
.on('error', console.log)
.pipe(gulp.dest('./public/'))
});
// Javascript
gulp.task('js', function(){
gulp.src(['./app/js/**/*.js', '!./app/js/vendor/**/*.js'])
.pipe(concat('app.js'))
.pipe(gulp.dest('./public/js'))
});
// Copy images, except icons.
gulp.task('images', function(){
gulp.src(['./app/img/**', '!./app/img/icons{,/**}',])
.pipe(gulp.dest('./public/img'))
});
// Copy fonts
gulp.task('fonts', function(){
gulp.src('./app/fonts/**')
.pipe(gulp.dest('./public/fonts/'));
});
// Browser-sync
gulp.task('browser-sync', function(){
browserSync.init(['./public/*.html', './public/css/*.css', './public/js/**/*.js', './public/img/*'], {
server: {
host: 'localhost',
baseDir: './public'
}
});
});
// Gulp watch with browser-sync
gulp.task('watch', function(){
// At start
gulp.start('stylus');
gulp.start('jade');
gulp.start('fonts');
gulp.start('sprite');
gulp.start('images');
gulp.start('browser-sync');
gulp.watch('app/styl/**/*.styl', ['stylus']);
gulp.watch('app/views/**/*.jade', ['jade']);
gulp.watch('app/js/**/*', ['js']);
gulp.watch('app/img/**/*', ['images']);
gulp.watch('app/img/icons/*.png', ['sprite']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment