Skip to content

Instantly share code, notes, and snippets.

@jvik
Created June 25, 2019 07:43
Show Gist options
  • Save jvik/0a62b68d70e8cb7a3e65ae20c0e6328a to your computer and use it in GitHub Desktop.
Save jvik/0a62b68d70e8cb7a3e65ae20c0e6328a to your computer and use it in GitHub Desktop.
problem with webpack-hot-middleware
import express from 'express';
import webpack from 'webpack';
import webpackConfig from '../webpack.config.js';
import * as webpackDevMiddleware from 'webpack-dev-middleware';
import * as webpackHotMiddleware from 'webpack-hot-middleware';
const app = express();
const port = 8080; // default port to listen
const compiler = webpack(webpackConfig as any);
// define a route handler for the default home page
app.use(
webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: webpackConfig.output.publicPath,
writeToDisk: true,
hot: true,
stats: { colors: true },
})
);
app.use(
webpackHotMiddleware(compiler, {
log: console.log,
})
);
app.get('/', (req, res) => {
res.send('Hello world!!!!');
});
// start the Express server
app.listen(port, () => {
console.log(`server started at http://localhost:${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment