Created
February 17, 2014 12:39
-
-
Save johanhalse/9049840 to your computer and use it in GitHub Desktop.
JavaScript concatenation and uglification with Harp server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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