Skip to content

Instantly share code, notes, and snippets.

@uzimith
Created January 4, 2015 09:00
Show Gist options
  • Save uzimith/effb26aa8c97ab35af80 to your computer and use it in GitHub Desktop.
Save uzimith/effb26aa8c97ab35af80 to your computer and use it in GitHub Desktop.
_ = require 'lodash'
gulp = require 'gulp'
plumber = require 'gulp-plumber'
util = require 'gulp-util'
browserify = require 'browserify'
source = require 'vinyl-source-stream'
streamify = require 'gulp-streamify'
watchify = require 'watchify'
SOURCE_DIR = './source/javascripts/_src/'
DIST_DIR = './source/javascripts/'
FILE = ['main']
gulp.task 'browserify', ->
_.each FILE, (fileName) ->
browserify
entries: ["#{SOURCE_DIR}#{fileName}.jsx"]
extensions: ['.coffee']
.bundle()
.pipe source("_#{fileName}.js")
.pipe gulp.dest(DIST_DIR + '/')
gulp.task 'watchify', ->
_.each FILE, (fileName) ->
bundler = watchify(browserify
entries: ["#{SOURCE_DIR}#{fileName}.jsx"]
extensions: ['.coffee']
)
rebundle = (fileName) ->
util.log("'#{fileName}.coffee' has changed.")
bundler.bundle()
.on 'error', (err) -> util.log('Browserify Error:', err)
.pipe plumber()
.pipe source "_#{fileName}.js"
.pipe gulp.dest(DIST_DIR + '/')
bundler.on 'update', -> rebundle(fileName)
rebundle(fileName)
{
"name": "uzimith.github.io",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"lodash": "*"
},
"browserify": {
"transform": [
"coffeeify",
"debowerify",
["reactify", {"es6": true}]
]
},
"devDependencies": {
"coffee-script": "*",
"vinyl-source-stream": "*",
"vinyl-buffer": "*",
"gulp": "*",
"gulp-coffee": "*",
"gulp-util": "*",
"gulp-plumber": "*",
"gulp-streamify": "*",
"bower": "*",
"browserify": "*",
"watchify": "*",
"coffeeify": "*",
"debowerify": "*",
"react": "*",
"esprima-fb": "*",
"reactify": "*"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/uzimith/uzimith.github.io.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/uzimith/uzimith.github.io/issues"
},
"homepage": "https://github.com/uzimith/uzimith.github.io"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment