Skip to content

Instantly share code, notes, and snippets.

@asyncanup
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asyncanup/5662e31ce336972c0c68 to your computer and use it in GitHub Desktop.
Save asyncanup/5662e31ce336972c0c68 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
UglifyJS = require('uglify-js');
var express = require('express'),
app = express();
var repo = process.argv[2];
var html = fs.readFileSync(__dirname + '/' + repo + '/build/index.html').toString();
var js = UglifyJS.minify(__dirname + '/' + repo + '/build/' + repo + '.bundle.js').code;
//js = fs.readFileSync(__dirname + '/' + repo + '/build/' + repo + '.bundle.js').toString();
html = html.replace('<script src="' + repo + '.bundle.js"></script>', '<script>' + js + '</script>');
console.log('start serving');
app.get('/index.html', function (req, res) {
console.log('new request');
res.send(html);
});
app.use(express.static(repo + '/build'));
app.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment