Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: compo
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 36 lines (26 sloc) 0.991 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
fs = require 'fs'
connect = require 'connect'
browserify = require 'browserify'
uglify = require 'uglify-js'

main = './game.coffee'


option '-c', '--compress', "Enable bundle compression"
option '-p', '--port', "Port to listen on"


# Write a compressed bundle for static serving in production.
task 'build', (options) ->
  b = browserify()
  b.register 'post', uglify if options.compress
  b.require main, root: __dirname
  fs.writeFileSync 'game.js', b.bundle()


# Watch and serve using browserify, for easy developent.
task 'serve', (options) ->
  b = browserify mount: '/game.js'
  b.register 'post', uglify if options.compress
  b.require main, root: __dirname, watch: yes

  server = connect.createServer()
  server.use connect.logger()
  server.use b
  server.use connect.static __dirname

  server.listen options.port or 20080, ->
    { address, port } = server.address()
    address = '127.0.0.1' if address is '0.0.0.0'
    console.log "Listening on http://#{address}:#{port}/"
Something went wrong with that request. Please try again.