Skip to content

Instantly share code, notes, and snippets.

@bretthadley
Created December 17, 2015 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bretthadley/3176bc84ee30a5f45fa4 to your computer and use it in GitHub Desktop.
Save bretthadley/3176bc84ee30a5f45fa4 to your computer and use it in GitHub Desktop.
import path from 'path';
import express from 'express';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import appConfig from '../tools/config';
const app = express();
const port = 3000;
const compiler = webpack(appConfig);
app.use(webpackDevMiddleware(compiler, { noInfo: true, lazy: false, publicPath: appConfig.output.publicPath }));
app.use(webpackHotMiddleware(compiler));
app.use(express.static(path.join(__dirname, 'public')));
app.use(function(req, res) {
res.sendFile(__dirname + '/public/index.html')
});
const server = app.listen(port, function (err) {
if(err) {
console.log('Error');
} else {
let port = server.address().port;
let host = server.address().address;
console.log('Listening at http://%s:%s', host, port);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment