Skip to content

Instantly share code, notes, and snippets.

@pnlybubbles
Last active December 10, 2015 11:30
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 pnlybubbles/db03a89d163b22fe0573 to your computer and use it in GitHub Desktop.
Save pnlybubbles/db03a89d163b22fe0573 to your computer and use it in GitHub Desktop.
gulpfile.coffee
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', [
'build:coffee',
'build:cjsx'
]
gulp.task 'build:coffee', ->
gulp
.src 'src/**/*.coffee'
.pipe plumber()
.pipe coffee()
.pipe gulp.dest('lib')
gulp.task 'build:cjsx', ->
gulp
.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) ->
gulp
.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'], ->
gulp.watch 'src/**/*.coffee', ['build:coffee']
gulp.watch 'src/**/*.cjsx', ['build:cjsx']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment