Last active
August 29, 2015 14:16
-
-
Save yymm/49c44016ac0087944490 to your computer and use it in GitHub Desktop.
Gulp, browserify, reactify, coffee-reactify, notify and watchify for coffeescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Ref: | |
# * https://gist.github.com/vojd/a2d277bc161a2674aeaa | |
# * https://gist.github.com/Sigmus/9253068 | |
# | |
source = require 'vinyl-source-stream' | |
gulp = require 'gulp' | |
gutil = require 'gulp-util' | |
browserify = require 'browserify' | |
coffee_reactify = require 'coffee-reactify' | |
watchify = require 'watchify' | |
notify = require 'gulp-notify' | |
paths = | |
srcFiles: ['./src/app.coffee'] | |
build: './build/' | |
buildFile: 'bundle.js' | |
buildScript = (files, watch) -> | |
rebundle = -> | |
stream = bundler.bundle() | |
stream.on("error", notify.onError( | |
title: "Compile Error" | |
message: "<%= error.message %>" | |
)).pipe(source(paths.buildFile)).pipe gulp.dest(paths.build) | |
props = watchify.args | |
props.entries = files | |
props.debug = true | |
bundler = (if watch then watchify(browserify(props)) else browserify(props)) | |
bundler.transform coffee_reactify | |
bundler.on "update", -> | |
rebundle() | |
gutil.log "Rebundled..." | |
gutil.log paths.srcFiles | |
return | |
rebundle() | |
gulp.task "default", -> | |
buildScript paths.srcFiles, false | |
gulp.task "watch", ["default"], -> | |
buildScript paths.srcFiles, true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment