Skip to content

Commit

Permalink
only install extension in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jooy2 committed Oct 24, 2023
1 parent f701e52 commit a13844a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions buildAssets/builder/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*'
Expand Down
18 changes: 18 additions & 0 deletions src/main/index.dev.ts
Original file line number Diff line number Diff line change
@@ -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,
},
});
15 changes: 1 addition & 14 deletions src/main/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down

0 comments on commit a13844a

Please sign in to comment.