From 2a92a56d405358576513ebab5a65679f17ec46b8 Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Thu, 9 May 2024 15:12:48 +0000 Subject: [PATCH] chore(webpack): remove proxySetup path, import setupProxy directly --- client/config/paths.js | 1 - client/config/webpackDevServer.config.js | 12 +++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/client/config/paths.js b/client/config/paths.js index 3c913f11cc95..6d6de4cf6014 100644 --- a/client/config/paths.js +++ b/client/config/paths.js @@ -51,7 +51,6 @@ const config = { appSrc: resolveApp("src"), appTsConfig: resolveApp("tsconfig.json"), yarnLockFile: resolveApp("../yarn.lock"), - proxySetup: resolveApp("src/setupProxy.js"), publicUrlOrPath, libsPath: resolveApp("../libs"), moduleFileExtensions, diff --git a/client/config/webpackDevServer.config.js b/client/config/webpackDevServer.config.js index a6f4144b1795..1ac41cc23c5f 100644 --- a/client/config/webpackDevServer.config.js +++ b/client/config/webpackDevServer.config.js @@ -1,4 +1,3 @@ -import fs from "node:fs"; import evalSourceMapMiddleware from "react-dev-utils/evalSourceMapMiddleware.js"; import noopServiceWorkerMiddleware from "react-dev-utils/noopServiceWorkerMiddleware.js"; import ignoredFiles from "react-dev-utils/ignoredFiles.js"; @@ -6,16 +5,13 @@ import redirectServedPath from "react-dev-utils/redirectServedPathMiddleware.js" import paths from "./paths.js"; import getServerConfig from "./getHttpsConfig.js"; +import proxySetup from "../src/setupProxy.js"; const host = process.env.HOST || "0.0.0.0"; const sockHost = process.env.WDS_SOCKET_HOST; const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws' const sockPort = process.env.WDS_SOCKET_PORT; -const proxySetup = fs.existsSync(paths.proxySetup) - ? (await import("file://" + paths.proxySetup)).default - : null; - function config(proxy, allowedHost) { const disableFirewall = !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === "true"; @@ -111,10 +107,8 @@ function config(proxy, allowedHost) { evalSourceMapMiddleware(devServer) ); - if (proxySetup) { - // This registers user provided middleware for proxy reasons - proxySetup(devServer.app); - } + // This registers user provided middleware for proxy reasons + proxySetup(devServer.app); middlewares.push( // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match