insomnia/webpack/server.js

30 lines
646 B
JavaScript
Raw Normal View History

import express from 'express';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
2016-03-16 05:49:42 +00:00
2016-08-23 19:43:01 +00:00
import config from './webpack.config.development.babel';
2016-03-22 18:20:05 +00:00
const app = express();
const compiler = webpack(config);
2016-04-07 01:11:16 +00:00
const PORT = 3333;
2016-03-22 18:20:05 +00:00
app.use(webpackDevMiddleware(compiler, {
2016-03-16 05:49:42 +00:00
publicPath: config.output.publicPath,
noInfo: true,
stats: {
colors: true
}
2016-03-22 18:20:05 +00:00
}));
app.use(webpackHotMiddleware(compiler));
2016-03-22 18:20:05 +00:00
app.listen(PORT, 'localhost', err => {
2016-03-16 05:49:42 +00:00
if (err) {
console.error(err);
2016-03-22 18:20:05 +00:00
return;
2016-03-16 05:49:42 +00:00
}
2016-03-22 18:20:05 +00:00
console.log(`Listening at http://localhost:${PORT}`);
2016-03-16 05:49:42 +00:00
});