insomnia/webpack/server.js

27 lines
545 B
JavaScript
Raw Normal View History

2016-03-22 18:20:05 +00:00
'use strict';
2016-03-16 05:49:42 +00:00
2016-03-22 18:20:05 +00:00
const express = require('express');
const webpack = require('webpack');
const config = require('../webpack/dev.config');
const app = express();
const compiler = webpack(config);
const PORT = 3000;
app.use(require('webpack-dev-middleware')(compiler, {
2016-03-16 05:49:42 +00:00
publicPath: config.output.publicPath,
2016-03-22 18:20:05 +00:00
stats: {colors: true}
}));
app.use(require('webpack-hot-middleware')(compiler));
app.listen(PORT, 'localhost', err => {
2016-03-16 05:49:42 +00:00
if (err) {
2016-03-22 18:20:05 +00:00
console.log(err);
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
});