1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 01:08:27 +00:00
trezor-wallet/webpack/server.js

35 lines
966 B
JavaScript

import express from 'express';
import webpack from 'webpack';
import open from 'open';
import { argv } from 'yargs';
import { SRC, PORT, INDEX, ABSOLUTE_BASE, TREZOR_CONNECT } from './constants';
//import config from './webpack.config.library';
const config = argv.connect ? require('./webpack.config.connect') : require('./webpack.config.dev');
const app = express();
const compiler = webpack(config);
app.use(require('webpack-dev-middleware')(compiler, {
contentBase: '/',
hot: true,
inline: true,
compress: true,
noInfo: false,
stats: { colors: true }
}));
app.use(require('webpack-hot-middleware')(compiler));
app.get('*', function(req, res) {
res.sendFile(SRC + req.params[0]);
});
app.listen(PORT, 'localhost', function(err) {
if (err) {
console.log(err);
return;
}
open(`http://localhost:${PORT}/`);
console.log(`Listening at http://localhost:${PORT}`);
console.log(`Serving ${INDEX}`);
});