Skip to content

Instantly share code, notes, and snippets.

@johanhalse
Created February 17, 2014 12:39
Show Gist options
  • Save johanhalse/9049840 to your computer and use it in GitHub Desktop.
Save johanhalse/9049840 to your computer and use it in GitHub Desktop.
JavaScript concatenation and uglification with Harp server
// Wrapper for Harp web server, to include JS concat/compile step. Put your stuff
// in /harp subdirectory, npm install your dependencies, run, enjoy.
// Live updating of the concatenated JS file left as an exercise for the reader :)
var fs = require('fs');
var path = require('path');
var harp = require('harp');
var UglifyJS = require('uglify-js');
var files = [];
files.push(__dirname + '/harp/js/file0.js');
files.push(__dirname + '/harp/js/file1.js');
fs.writeFile(__dirname + '/harp/js/main.min.js', UglifyJS.minify( files ).code, 'utf8', function(err) {
if(err) {
console.log(err);
}
else {
harp.server(__dirname + '/harp', {
port: 9000
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment