mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
debugging webpack@5 usage -- part 1
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
f4f937dc92
commit
ab7781fdcd
5 files changed
+45
-27
No files matched your search
+15
-13
@@ -9,7 +9,7 @@ import type http from "http";
|
||||
import path from "path";
|
||||
import { readFile } from "fs-extra";
|
||||
import type { Cluster } from "../common/cluster/cluster";
|
||||
import { apiPrefix, appName, publicPath, isDevelopment, webpackDevServerPort } from "../common/vars";
|
||||
import { apiPrefix, appName, publicPath } from "../common/vars";
|
||||
import { HelmApiRoute, KubeconfigRoute, MetricsRoute, PortForwardRoute, ResourceApplierApiRoute, VersionRoute } from "./routes";
|
||||
import logger from "./logger";
|
||||
|
||||
@@ -110,7 +110,7 @@ export class Router {
|
||||
};
|
||||
}
|
||||
|
||||
protected static async handleStaticFile({ params, response, raw: { req }}: LensApiRequest): Promise<void> {
|
||||
protected static async handleStaticFile({ params, response }: LensApiRequest): Promise<void> {
|
||||
let filePath = params.path;
|
||||
|
||||
for (let retryCount = 0; retryCount < 5; retryCount += 1) {
|
||||
@@ -124,18 +124,20 @@ export class Router {
|
||||
}
|
||||
|
||||
try {
|
||||
const filename = path.basename(req.url);
|
||||
// const filename = path.basename(req.url);
|
||||
// redirect requests to [appName].js, [appName].html /sockjs-node/ to webpack-dev-server (for hot-reload support)
|
||||
const toWebpackDevServer = filename.includes(appName) || filename.includes("hot-update") || req.url.includes("sockjs-node");
|
||||
|
||||
if (isDevelopment && toWebpackDevServer) {
|
||||
const redirectLocation = `http://localhost:${webpackDevServerPort}${req.url}`;
|
||||
|
||||
response.statusCode = 307;
|
||||
response.setHeader("Location", redirectLocation);
|
||||
|
||||
return response.end();
|
||||
}
|
||||
// const toWebpackDevServer = filename.includes(appName) || filename.includes("hot-update") || req.url.includes("sockjs-node");
|
||||
//
|
||||
// if (isDevelopment /*&& toWebpackDevServer*/) {
|
||||
// const redirectLocation = `http://0.0.0.0:${webpackDevServerPort}${req.url}`;
|
||||
//
|
||||
// logger.info(`[ROUTER]: redirecting to dev-server url: ${redirectLocation}`);
|
||||
//
|
||||
// response.statusCode = 307;
|
||||
// response.setHeader("Location", redirectLocation);
|
||||
//
|
||||
// return response.end();
|
||||
// }
|
||||
|
||||
const data = await readFile(asset);
|
||||
|
||||
|
||||
Reference in new issue
Block a user