Skip to content
This repository has been archived by the owner on Dec 27, 2018. It is now read-only.

Commit

Permalink
use watchify instead of beefy for faster builds
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsk committed Aug 24, 2013
1 parent e78e0bb commit 4c48857
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"description": "ERROR: No README.md file found!",
"scripts": {
"start": "beefy index.js:bundle.js --live",
"start": "node server.js",
"bundle": "browserify index.js | uglifyjs -c > bundle.js",
"test": "say sorry"
},
Expand All @@ -18,7 +18,9 @@
"devDependencies": {
"beefy": "~0.4.1",
"browserify": "~2.28.0",
"uglify-js": "~2.4.0"
"uglify-js": "~2.4.0",
"watchify": "~0.1.0",
"ecstatic": "~0.4.7"
},
"dependencies": {
"image-loaded": "0.0.2",
Expand Down
27 changes: 27 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var watchify = require('watchify')
var ecstatic = require('ecstatic')
var http = require('http')

var st = ecstatic(__dirname)
var br = require('browserify')({
entries: [__dirname + '/index.js']
})

var n = 0
var server = http.createServer(function(req, res) {
if (req.url !== '/bundle.js') return st(req, res, function(err) {
return res.end('404: ' + req.url)
})


var i = n++
console.time('build #' + i)
res.setHeader('Content-Type', 'application/javascript')
br.bundle().once('end', function() {
console.timeEnd('build #' + i)
}).pipe(res)
})

server.listen(9966, function() {
console.log('listening on port 9966')
})

0 comments on commit 4c48857

Please sign in to comment.