mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
attempt to use webpack-dev-server via node-api -- part 2
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
92a5c785a3
commit
f1efed4d78
5 files changed
+22
-37
No files matched your search
+6
-4
@@ -178,10 +178,6 @@ di.runSetups().then(() => {
|
||||
try {
|
||||
logger.info("🔌 Starting LensProxy");
|
||||
await lensProxy.listen();
|
||||
|
||||
if (isDevelopment) {
|
||||
await createDevServer(lensProxy.port).start();
|
||||
}
|
||||
} catch (error) {
|
||||
dialog.showErrorBox("Lens Error", `Could not start proxy: ${error?.message || "unknown error"}`);
|
||||
|
||||
@@ -233,6 +229,12 @@ di.runSetups().then(() => {
|
||||
logger.info("🖥️ Starting WindowManager");
|
||||
const windowManager = WindowManager.createInstance();
|
||||
|
||||
if (isDevelopment) {
|
||||
const devServer = createDevServer(lensProxy.port);
|
||||
await devServer.start(); // waiting dev-server to start
|
||||
windowManager.mainContentUrl = `http://localhost:${devServer.options.port}`;
|
||||
}
|
||||
|
||||
const menuItems = di.inject(electronMenuItemsInjectable);
|
||||
const trayMenuItems = di.inject(trayMenuItemsInjectable);
|
||||
|
||||
|
||||
@@ -124,21 +124,6 @@ export class Router {
|
||||
}
|
||||
|
||||
try {
|
||||
// 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}`;
|
||||
//
|
||||
// logger.info(`[ROUTER]: redirecting to dev-server url: ${redirectLocation}`);
|
||||
//
|
||||
// response.statusCode = 307;
|
||||
// response.setHeader("Location", redirectLocation);
|
||||
//
|
||||
// return response.end();
|
||||
// }
|
||||
|
||||
const data = await readFile(asset);
|
||||
|
||||
response.setHeader("Content-Type", getMimeType(asset));
|
||||
|
||||
@@ -34,6 +34,7 @@ export class WindowManager extends Singleton {
|
||||
protected disposers: Record<string, Function> = {};
|
||||
|
||||
@observable activeClusterId: ClusterId;
|
||||
@observable mainContentUrl = `http://localhost:${LensProxy.getInstance().port}`;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -41,10 +42,6 @@ export class WindowManager extends Singleton {
|
||||
this.bindEvents();
|
||||
}
|
||||
|
||||
get mainUrl() {
|
||||
return `http://localhost:${LensProxy.getInstance().port}`;
|
||||
}
|
||||
|
||||
private async initMainWindow(showSplash: boolean) {
|
||||
// Manage main window size and position with state persistence
|
||||
if (!this.windowState) {
|
||||
@@ -142,8 +139,8 @@ export class WindowManager extends Singleton {
|
||||
|
||||
try {
|
||||
if (showSplash) await this.showSplash();
|
||||
logger.info(`[WINDOW-MANAGER]: Loading Main window from url: ${this.mainUrl} ...`);
|
||||
await this.mainWindow.loadURL(this.mainUrl);
|
||||
logger.info(`[WINDOW-MANAGER]: Loading Main window from url: ${this.mainContentUrl} ...`);
|
||||
await this.mainWindow.loadURL(this.mainContentUrl);
|
||||
} catch (error) {
|
||||
logger.error("Loading main window failed", { error });
|
||||
dialog.showErrorBox("ERROR!", error.toString());
|
||||
|
||||
Reference in new issue
Block a user