graphql-engine/console/webpack/webpack-dev-server.js
2018-06-28 10:27:37 +05:30

37 lines
906 B
JavaScript
Executable File

const Express = require('express');
const webpack = require('webpack');
const webpackConfig = require('./dev.config');
const compiler = webpack(webpackConfig);
const hasuraConfig = require('../hasuraconfig');
const host = hasuraConfig.hmrHost;
const port = hasuraConfig.hmrPort;
const serverOptions = {
contentBase: 'http://' + host + ':' + port,
logLevel: 'silent',
hot: true,
inline: true,
lazy: false,
publicPath: webpackConfig.output.publicPath,
headers: { 'Access-Control-Allow-Origin': '*' },
stats: { colors: true },
};
const app = new Express();
app.use(require('webpack-dev-middleware')(compiler, serverOptions));
app.use(require('webpack-hot-middleware')(compiler));
app.listen(port, function onAppListening(err) {
if (err) {
console.error(err);
} else {
console.info(
'==> 🚧 Webpack development server listening on port %s',
port
);
}
});