Webpack Express Reload
Autoreload webpack app running through an express server. Not HMR. Works with webpack-dev-middleware
.
Installation
npm install -D webpack-express-reload
Inside your server.js file convert your express server into a server that supports live-reload using SockJS.
const express = ;const path = ;const app = ; const Webpack = const middleware = ;const webpackConfig = ; const PORT = processenvPORT || 3001;const HOST = processenvHOST || '0.0.0.0'; const compiler = ; app;app const server = app compiler path: '/_testapp'; server;
Inside your webpack.config.js add the webpack-express-reload client. Specify the url to connect to the server using ?http://0.0.0.0:3001/_testapp
where /_testapp
os the path defined in the server config.
const path = ; moduleexports = entry: path `webpack-express-reload/client?http://0.0.0.0:3001/_testapp` mode: processenvNODE_ENV || 'development' output: path: path filename: 'bundle.js' publicPath: '/'