Created
June 25, 2019 07:43
-
-
Save jvik/0a62b68d70e8cb7a3e65ae20c0e6328a to your computer and use it in GitHub Desktop.
problem with webpack-hot-middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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