Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement