Last active
August 29, 2015 14:22
-
-
Save asyncanup/5662e31ce336972c0c68 to your computer and use it in GitHub Desktop.
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
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