2016-04-20 02:14:53 +00:00
|
|
|
import express from 'express';
|
|
|
|
import webpack from 'webpack';
|
|
|
|
import webpackDevMiddleware from 'webpack-dev-middleware';
|
|
|
|
import webpackHotMiddleware from 'webpack-hot-middleware';
|
2016-10-21 17:20:36 +00:00
|
|
|
import {parse as urlParse} from 'url';
|
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-20 02:14:53 +00:00
|
|
|
app.use(webpackDevMiddleware(compiler, {
|
2016-03-16 05:49:42 +00:00
|
|
|
publicPath: config.output.publicPath,
|
2016-08-15 17:04:36 +00:00
|
|
|
noInfo: true,
|
2016-04-20 02:14:53 +00:00
|
|
|
stats: {
|
|
|
|
colors: true
|
|
|
|
}
|
2016-03-22 18:20:05 +00:00
|
|
|
}));
|
|
|
|
|
2016-04-20 02:14:53 +00:00
|
|
|
app.use(webpackHotMiddleware(compiler));
|
2016-03-22 18:20:05 +00:00
|
|
|
|
2016-10-21 17:20:36 +00:00
|
|
|
const parsedUrl = urlParse(config.output.publicPath);
|
|
|
|
app.listen(parsedUrl.port, parsedUrl.hostname, err => {
|
2016-03-16 05:49:42 +00:00
|
|
|
if (err) {
|
2016-04-20 02:14:53 +00:00
|
|
|
console.error(err);
|
2016-03-22 18:20:05 +00:00
|
|
|
return;
|
2016-03-16 05:49:42 +00:00
|
|
|
}
|
|
|
|
|
2016-10-21 17:20:36 +00:00
|
|
|
console.log(`Listening at http://${parsedUrl.hostname}:${parsedUrl.port}`);
|
2016-03-16 05:49:42 +00:00
|
|
|
});
|