From a13844a809864ff9c100b3ac9290d29f9eca298a Mon Sep 17 00:00:00 2001 From: leejooy96 Date: Tue, 24 Oct 2023 18:03:55 +0900 Subject: [PATCH] only install extension in debug mode --- buildAssets/builder/config.js | 1 + src/main/index.dev.ts | 18 ++++++++++++++++++ src/main/index.ts | 15 +-------------- vite.config.ts | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 src/main/index.dev.ts 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(); },