Skip to content

Instantly share code, notes, and snippets.

@mucahitgurbuz
Created April 13, 2021 13:51
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/7801dfa2bb1fb868ff1902fb7f35369a to your computer and use it in GitHub Desktop.
Save mucahitgurbuz/7801dfa2bb1fb868ff1902fb7f35369a to your computer and use it in GitHub Desktop.
webpack-dev-server Version 3 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 ignoredFiles = require('react-dev-utils/ignoredFiles');
const paths = require('./paths');
const fs = require('fs');
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const host = process.env.HOST || '0.0.0.0';
module.exports = function(proxy, allowedHost) {
return {
disableHostCheck: !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
compress: true,
clientLogLevel: 'none',
contentBase: paths.appPublic,
watchContentBase: true,
transportMode: 'ws',
injectClient: false,
publicPath: '/',
quiet: true,
watchOptions: {
ignored: ignoredFiles(paths.appSrc),
},
https: protocol === 'https',
host,
overlay: false,
historyApiFallback: {
disableDotRule: true,
},
public: allowedHost,
proxy,
before(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