Instantly share code, notes, and snippets.

What would you like to do?
gulp = require 'gulp'
plumber = require 'gulp-plumber'
coffee = require 'gulp-coffee'
coffee_react = require 'gulp-cjsx'
watchify = require 'gulp-watchify'
rename = require 'gulp-rename'
uglify = require 'gulp-uglify'
sourcemaps = require 'gulp-sourcemaps'
buffer = require 'vinyl-buffer'
gulp.task 'default', ['build']
gulp.task 'build', [
gulp.task 'build:coffee', ->
.src 'src/**/*.coffee'
.pipe plumber()
.pipe coffee()
.pipe gulp.dest('lib')
gulp.task 'build:cjsx', ->
.src 'src/**/*.cjsx'
.pipe plumber()
.pipe coffee_react()
.pipe gulp.dest('lib')
watching = false
gulp.task 'enable-watch-mode', -> watching = true
gulp.task 'browserify', watchify (watchify) ->
.src 'lib/main.js'
.pipe watchify
watch: watching
debug: true
.pipe buffer()
.pipe sourcemaps.init
loadMaps: true
.pipe uglify()
.pipe rename('bundle.js')
.pipe sourcemaps.write('./')
.pipe gulp.dest('public/js')
gulp.task 'watchify', ['enable-watch-mode', 'browserify']
gulp.task 'watch', ['build', 'enable-watch-mode', 'watchify'], -> 'src/**/*.coffee', ['build:coffee'] 'src/**/*.cjsx', ['build:cjsx']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment