Skip to content

Instantly share code, notes, and snippets.

@yymm
Last active September 15, 2016 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yymm/cf8d49843b39541afcfe to your computer and use it in GitHub Desktop.
Save yymm/cf8d49843b39541afcfe to your computer and use it in GitHub Desktop.
My nodejs proj bootstraping (browserify & coffeescript (& react.js) )
# once
npm install -g electron-prebuilt gulp node-gyp
# per proj
npm install -save-dev vinyl-source-stream gulp gulp-util browserify coffee-reactify watchify gulp-notify coffee-script coffeeify
mkdir src
mkdir bundle
touch app.coffee
# shop
npm install -save react
npm install -save react superagent
source = require 'vinyl-source-stream'
gulp = require 'gulp'
gutil = require 'gulp-util'
browserify = require 'browserify'
coffee_reactify = require 'coffee-reactify'
coffeeify = require 'coffeeify'
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.transform coffeeify
bundler.on "update", ->
rebundle()
gutil.log "Rebundled..."
return
rebundle()
gulp.task "default", ->
buildScript paths.srcFiles, false
gulp.task "watch", ["default"], ->
buildScript paths.srcFiles, true
{
"name": "your app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": ""
}
gulp = require 'gulp'
coffee = require 'gulp-coffee'
files = './src/*.coffee'
gulp.task 'js', ->
gulp.src files
.pipe coffee
bare: true
.pipe gulp.dest './build'
gulp.task 'watch', ['build'], ->
gulp.watch files, ['js']
gulp.task 'build', ['js']
gulp.task 'default', ['build']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment