Skip to content

Commit

Permalink
refactor: dev configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Enubia committed Feb 20, 2024
1 parent 8fe214f commit 4c51197
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 146 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

23 changes: 0 additions & 23 deletions .vscode/.debug.script.mjs

This file was deleted.

53 changes: 0 additions & 53 deletions .vscode/launch.json

This file was deleted.

31 changes: 0 additions & 31 deletions .vscode/tasks.json

This file was deleted.

26 changes: 16 additions & 10 deletions electron/main/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const store = createStore();

log.info('Store created');

// paths relative to the output directory (dist, dist-electron)
const DIST_ELECTRON = join(__dirname, '..');
const DIST = join(DIST_ELECTRON, '../dist');
const PUBLIC = process.env.VITE_DEV_SERVER_URL ? join(DIST_ELECTRON, '../public') : DIST;
Expand Down Expand Up @@ -78,9 +79,11 @@ app.on('ready', () => {
},
process.platform === 'linux' ? 1000 : 0,
);

// Registering the Keybind on the start of the App
// Since all Keys are unregistered at close
const keybind = store.get('keybind').vanishKeybind;

if (keybind) {
try {
globalShortcut.register(keybind, () => {
Expand Down Expand Up @@ -122,21 +125,24 @@ app.on('activate', () => {

app.on('window-all-closed', () => {
overlay = null;
if (process.platform === 'darwin') {
if (store.get('general').mac.quitOnClose) {
log.info('unregistering all shortcut');

const quit = () => {
if (store.get('keybind').vanishKeybind) {
log.info('unregistering all shortcuts');
globalShortcut.unregisterAll();
}

log.info('App closing');
app.quit();
};

log.info('App closing');
app.quit();
if (process.platform === 'darwin') {
if (store.get('general').mac.quitOnClose) {
quit();
} else {
app.dock.show();
}
} else {
log.info('unregistering all shortcut');
globalShortcut.unregisterAll();

log.info('App closing');
app.quit();
quit();
}
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
}
},
"engines": {
"node": ">=20.11.0",
"pnpm": ">=8.15.1"
"node": ">=20",
"pnpm": ">=8"
},
"scripts": {
"build": "vue-tsc --noEmit && vite build",
Expand Down
29 changes: 3 additions & 26 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ import { defineConfig } from 'vite';
import electron from 'vite-plugin-electron';
import renderer from 'vite-plugin-electron-renderer';

import pkg from './package.json';

// https://vitejs.dev/config/
export default defineConfig((({ command }) => {
rmSync('dist-electron', { recursive: true, force: true });

const isServe = command === 'serve';
const isBuild = command === 'build';
const sourcemap = isServe || !!process.env.VSCODE_DEBUG;

return {
plugins: [
Expand All @@ -31,28 +27,18 @@ export default defineConfig((({ command }) => {
include: resolve(__dirname, './i18n/locales/**'),
runtimeOnly: false,
}),

electron([
{
// Main-Process entry file of the Electron App.
entry: 'electron/main/background.ts',
onstart(options) {
if (process.env.VSCODE_DEBUG) {
// eslint-disable-next-line no-console
console.log(/* For `.vscode/.debug.script.mjs` */ '[startup] Electron App');
} else {
options.startup();
}
options.startup();
},
vite: {
build: {
sourcemap,
sourcemap: isServe,
minify: isBuild,
outDir: 'dist-electron/main',
rollupOptions: {
external: Object.keys(
'dependencies' in pkg ? pkg.dependencies : ({} as unknown as any),
),
},
},
},
},
Expand All @@ -61,15 +47,6 @@ export default defineConfig((({ command }) => {
// Use Node.js API in the Renderer-process
renderer(),
],
server:
process.env.VSCODE_DEBUG
&& (() => {
const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL);
return {
host: url.hostname,
port: +url.port,
};
})(),
clearScreen: false,
};
}) as UserConfigFn);

0 comments on commit 4c51197

Please sign in to comment.