Created
April 13, 2021 13:54
-
-
Save mucahitgurbuz/d1c2af133fa1011428d97e08c8fda10b to your computer and use it in GitHub Desktop.
webpack-dev-server Version 4 Configuration Example
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
'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