diff --git a/buildAssets/builder/config.js b/buildAssets/builder/config.js index 7344567..ff9de78 100644 --- a/buildAssets/builder/config.js +++ b/buildAssets/builder/config.js @@ -100,6 +100,7 @@ baseConfig.files = [ (Required) The files and folders listed below should not be included in the build. */ 'dist/**/*', + '!dist/main/index.dev.js', '!docs/**/*', '!tests/**/*', '!release/**/*' diff --git a/src/main/index.dev.ts b/src/main/index.dev.ts new file mode 100644 index 0000000..d0463e9 --- /dev/null +++ b/src/main/index.dev.ts @@ -0,0 +1,18 @@ +// Warning: This file is only used in the development environment +// and is removed at build time. +// Do not edit the file unless necessary. +import installExtension, { + REACT_DEVELOPER_TOOLS, + REDUX_DEVTOOLS, +} from 'electron-extension-installer'; + +installExtension(REACT_DEVELOPER_TOOLS, { + loadExtensionOptions: { + allowFileAccess: true, + }, +}); +installExtension(REDUX_DEVTOOLS, { + loadExtensionOptions: { + allowFileAccess: true, + }, +}); diff --git a/src/main/index.ts b/src/main/index.ts index c70d5cf..2d2074d 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,10 +1,6 @@ import { app, BrowserWindow, systemPreferences } from 'electron'; import { join } from 'path'; -import installExtension, { - REACT_DEVELOPER_TOOLS, - REDUX_DEVTOOLS, -} from 'electron-extension-installer'; import IPCs from './IPCs'; global.IS_DEV = process.env.NODE_ENV === 'development'; @@ -68,16 +64,7 @@ app.whenReady().then(async () => { } if (global.IS_DEV) { - await installExtension(REACT_DEVELOPER_TOOLS, { - loadExtensionOptions: { - allowFileAccess: true, - }, - }); - await installExtension(REDUX_DEVTOOLS, { - loadExtensionOptions: { - allowFileAccess: true, - }, - }); + import('./index.dev'); } await createWindow(); diff --git a/vite.config.ts b/vite.config.ts index 417d4d3..0dc91f1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -36,7 +36,7 @@ export default defineConfig(() => { // Docs: https://github.com/electron-vite/vite-plugin-electron ElectronPlugin([ { - entry: ['src/main/index.ts'], + entry: ['src/main/index.ts', 'src/main/index.dev.ts'], onstart: (options) => { options.startup(); },