Skip to content

Instantly share code, notes, and snippets.

@lmartins
Created February 16, 2014 17:07
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 lmartins/9037335 to your computer and use it in GitHub Desktop.
Save lmartins/9037335 to your computer and use it in GitHub Desktop.
gulp = require 'gulp'
gutil = require 'gulp-util'
sass = require 'gulp-sass'
prefix = require 'gulp-autoprefixer'
coffee = require 'gulp-coffee'
coffeelint = require 'gulp-coffeelint'
concat = require 'gulp-concat'
plumber = require 'gulp-plumber'
changed = require 'gulp-changed'
uglify = require 'gulp-uglify'
imagemin = require 'gulp-imagemin'
livereload = require 'gulp-livereload'
component = require 'gulp-component'
lr = require 'tiny-lr'
server = lr()
notify = require 'gulp-notify'
options =
# HTML
HTML_SOURCE : "*.html",
# SASS / CSS
SASS_SOURCE : "src/sass/**/*.scss",
SASS_DEST : "build/css/",
# JavaScript
COFFEE_SOURCE : "src/coffee/**/*.coffee",
COFFEE_DEST : "build/js/",
# Images
IMAGE_SOURCE : "src/images/**/*",
IMAGE_DEST : "build/images",
# Icons
ICONS_SOURCE : "src/sass/app/components/icons/svg/*.svg",
ICONS_DEST : "build/css/fonts/",
# Live reload
LIVE_RELOAD_PORT: 35729
# Compile Our Sass
gulp.task 'sass', ->
gulp.src options.SASS_SOURCE
.pipe plumber()
.pipe sass
outputStyle: 'compressed'
.on "error", notify.onError()
.on "error", (err) ->
console.log("Error:", err)
.pipe prefix "last 2 versions"
.pipe gulp.dest options.SASS_DEST
.pipe livereload(server)
# Compile Our Coffee
gulp.task 'coffee', ->
gulp.src options.COFFEE_SOURCE
.pipe changed options.COFFEE_SOURCE
.pipe coffee
sourceMap: true
.on 'error', gutil.log
.pipe gulp.dest( options.COFFEE_DEST )
.pipe livereload( server )
gulp.task 'lint', ->
gulp.src options.COFFEE_SOURCE
.pipe coffeelint()
.pipe coffeelint.reporter()
gulp.task 'html', ->
gulp.src options.HTML_SOURCE
.pipe livereload(server)
gulp.task 'bowerCopy', ->
gulp.src [
'src/vendor/jquery/dist/jquery.min.js',
'src/vendor/script.js/dist/script.js'
]
.pipe uglify()
.pipe gulp.dest( "build/vendor/" )
gulp.task 'bowerMerge', ->
gulp.src [
'src/vendor/snapjs/snap.js',
'src/vendor/jquery-easing/jquery.easing.js'
]
.pipe concat "bundle.js"
.pipe uglify()
.pipe gulp.dest "build/vendor/"
gulp.task 'images', ->
gulp.src IMAGE_SOURCE
.pipe imagemin()
.pipe gulp.dest( IMAGE_DEST )
gulp.task 'default', ->
gulp.watch options.SASS_SOURCE, ['sass']
gulp.watch options.COFFEE_SOURCE, ['coffee','lint']
gulp.task 'bower', [ 'bowerCopy', 'bowerMerge' ]
gulp.task 'watch', ->
server.listen options.LIVE_RELOAD_PORT, (err) ->
if (err) then console.log(err)
gulp.watch options.HTML_SOURCE, ['html']
gulp.watch options.COFFEE_SOURCE, ['coffee','lint']
gulp.watch options.IMAGE_SOURCE, ['images']
gulp.watch options.SASS_SOURCE, ['sass']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment