-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathwebpack.config.js
34 lines (29 loc) · 959 Bytes
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict";
const http = require("http");
const httpProxy = require("http-proxy");
// our setup function adds behind-the-scenes bits to the config that all of our
// examples need
const { setup } = require("../util");
module.exports = setup({
context: __dirname,
entry: "./app.js",
devServer: {
webSocketServer: "ws",
onAfterSetupMiddleware: (server) => {
const proxyPort = 8080;
const proxyHost = "127.0.0.1";
const proxy = httpProxy.createProxyServer({
target: { socketPath: server.options.ipc },
});
const proxyServer = http.createServer((request, response) => {
// You can define here your custom logic to handle the request
// and then proxy the request.
proxy.web(request, response);
});
proxyServer.on("upgrade", (request, socket, head) => {
proxy.ws(request, socket, head);
});
proxyServer.listen(proxyPort, proxyHost);
},
},
});