Skip to content

Instantly share code, notes, and snippets.

@mucahitgurbuz
Created April 13, 2021 13:54
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 mucahitgurbuz/d1c2af133fa1011428d97e08c8fda10b to your computer and use it in GitHub Desktop.
Save mucahitgurbuz/d1c2af133fa1011428d97e08c8fda10b to your computer and use it in GitHub Desktop.
webpack-dev-server Version 4 Configuration Example
'use strict';
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const paths = require('./paths');
const fs = require('fs');
const host = process.env.HOST || '0.0.0.0';
module.exports = function(proxy, allowedHost) {
return {
compress: true,
static: [paths.appPublic],
dev: { publicPath: '/' },
host,
firewall: false,
historyApiFallback: {
disableDotRule: true,
},
public: allowedHost,
proxy,
port: 3000,
client: { progress: true, overlay: false, needClientEntry: false },
onBeforeSetupMiddleware(app, server) {
if (fs.existsSync(paths.proxySetup)) {
require(paths.proxySetup)(app);
}
app.use(evalSourceMapMiddleware(server));
app.use(errorOverlayMiddleware());
app.use(noopServiceWorkerMiddleware('/'));
},
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment