From d630a82dec580b36249ba47b6dacdd8d531e8709 Mon Sep 17 00:00:00 2001 From: leejooy96 Date: Tue, 24 Oct 2023 18:01:04 +0900 Subject: [PATCH] pack: only install extension in debug mode --- buildAssets/builder/config.js | 1 + src/main/index.dev.ts | 10 ++++++++++ src/main/index.ts | 7 +------ vite.config.ts | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 src/main/index.dev.ts diff --git a/buildAssets/builder/config.js b/buildAssets/builder/config.js index 6cc33470..b0ca3a15 100644 --- a/buildAssets/builder/config.js +++ b/buildAssets/builder/config.js @@ -98,6 +98,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 00000000..f3ac23ad --- /dev/null +++ b/src/main/index.dev.ts @@ -0,0 +1,10 @@ +// 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, VUEJS_DEVTOOLS } from 'electron-extension-installer' + +installExtension(VUEJS_DEVTOOLS, { + loadExtensionOptions: { + allowFileAccess: true + } +}) diff --git a/src/main/index.ts b/src/main/index.ts index 0b97e6fe..ae68f7e9 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -2,18 +2,13 @@ import { app, WebContents, RenderProcessGoneDetails } from 'electron' import Constants from './utils/Constants' import { createErrorWindow, createMainWindow } from './MainRunner' import { macOSDisableDefaultMenuItem } from './utils/Menus' -import { installExtension, VUEJS_DEVTOOLS } from 'electron-extension-installer' let mainWindow let errorWindow app.on('ready', async () => { if (Constants.IS_DEV_ENV) { - await installExtension(VUEJS_DEVTOOLS, { - loadExtensionOptions: { - allowFileAccess: true - } - }) + import('./index.dev') } macOSDisableDefaultMenuItem() diff --git a/vite.config.ts b/vite.config.ts index 768989e4..56f84b73 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -45,7 +45,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() },