Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(electron): webpack dev server reloading issue (#9978)

pengx1740305db83897
diff --git a/packages/frontend/apps/electron/src/main/index.ts b/packages/frontend/apps/electron/src/main/index.ts
index e3c6f8c174..70a68a6016 100644
--- a/packages/frontend/apps/electron/src/main/index.ts
+++ b/packages/frontend/apps/electron/src/main/index.ts
@@ -7,7 +7,7 @@ import { IPCMode } from '@sentry/electron/main';
import { app } from 'electron';
import { createApplicationMenu } from './application-menu/create';
-import { buildType, overrideSession } from './config';
+import { buildType, isDev, overrideSession } from './config';
import { persistentConfig } from './config-storage/persist';
import { setupDeepLink } from './deep-link';
import { registerEvents } from './events';
@@ -22,6 +22,12 @@ import { launchStage } from './windows-manager/stage';
app.enableSandbox();
app.commandLine.appendSwitch('enable-features', 'CSSTextAutoSpace');
+if (isDev) {
+ // In electron the dev server will be resolved to 0.0.0.0, but it
+ // might be blocked by electron.
+ // See https://github.com/webpack/webpack-dev-server/pull/384
+ app.commandLine.appendSwitch('host-rules', 'MAP 0.0.0.0 127.0.0.1');
+}
// https://github.com/electron/electron/issues/43556
app.commandLine.appendSwitch('disable-features', 'PlzDedicatedWorker');