gdumitrescu
2/17/2014 - 12:39 PM

JavaScript concatenation and uglification with Harp server

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
    });
  }
});