-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to
electron-vite
and electron-builder
- Switch from deprecated Vue CLI plugin to `electron-vite` (see nklayman/vue-cli-plugin-electron-builder#1982) - Update main/preload scripts to use `index.cjs` filenames to support `"type": "module"`, resolving crash issue (#233). This crash was related to Electron not supporting ESM (see electron/asar#249, electron/electron#21457). - This commit completes migration to Vite from Vue CLI (#230). Structure changes: - Introduce separate folders for Electron's main and preload processes. - Move TypeHelpers to `src/` to mark tit as accessible by the rest of the code. Config changes: - Make `vite.config.ts` reusable by Electron configuration. - On electron-builder, use `--publish` flag instead of `-p` for clarity. Tests: - Add log for preload script loading verification. - Implement runtime environment sanity checks. - Enhance logging in `check-desktop-runtime-errors`.
- Loading branch information
1 parent
aa94981
commit c34130c
Showing
43 changed files
with
1,014 additions
and
2,597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# ------- | ||
# Windows | ||
# ------- | ||
win: | ||
target: nsis | ||
nsis: | ||
artifactName: ${name}-${version}-Setup.${ext} | ||
|
||
# ----- | ||
# Linux | ||
# ----- | ||
linux: | ||
target: AppImage | ||
appImage: | ||
artifactName: ${name}-${version}.${ext} | ||
|
||
# ----- | ||
# macOS | ||
# ----- | ||
mac: | ||
target: dmg | ||
dmg: | ||
artifactName: ${name}-${version}.${ext} | ||
|
||
# ---------------- | ||
# Publish options | ||
# ---------------- | ||
publish: | ||
provider: 'github' | ||
vPrefixedTagName: false # default: true | ||
releaseType: release # default: draft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { resolve } from 'path'; | ||
import { mergeConfig, UserConfig } from 'vite'; | ||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'; | ||
import { getAliasesFromTsConfig, getClientEnvironmentVariables } from './vite-config-helper'; | ||
import { createVueConfig } from './vite.config'; | ||
|
||
const MAIN_ENTRY_FILE = resolvePathFromProjectRoot('src/presentation/electron/main/index.ts'); | ||
const PRELOAD_ENTRY_FILE = resolvePathFromProjectRoot('src/presentation/electron/preload/index.ts'); | ||
const WEB_INDEX_HTML_PATH = resolvePathFromProjectRoot('src/presentation/index.html'); | ||
const DIST_DIR = resolvePathFromProjectRoot('dist_electron/'); | ||
|
||
export default defineConfig({ | ||
main: getSharedElectronConfig({ | ||
distDirSubfolder: 'main', | ||
entryFilePath: MAIN_ENTRY_FILE, | ||
}), | ||
preload: getSharedElectronConfig({ | ||
distDirSubfolder: 'preload', | ||
entryFilePath: PRELOAD_ENTRY_FILE, | ||
}), | ||
renderer: mergeConfig( | ||
createVueConfig({ | ||
supportLegacyBrowsers: false, | ||
}), | ||
{ | ||
build: { | ||
outDir: resolve(DIST_DIR, 'renderer'), | ||
rollupOptions: { | ||
input: { | ||
index: WEB_INDEX_HTML_PATH, | ||
}, | ||
external: ['os', 'child_process', 'fs', 'path'], | ||
}, | ||
}, | ||
}, | ||
), | ||
}); | ||
|
||
function getSharedElectronConfig(options: { | ||
readonly distDirSubfolder: string; | ||
readonly entryFilePath: string; | ||
}): UserConfig { | ||
return { | ||
build: { | ||
outDir: resolve(DIST_DIR, options.distDirSubfolder), | ||
lib: { | ||
entry: options.entryFilePath, | ||
}, | ||
rollupOptions: { | ||
output: { | ||
entryFileNames: '[name].cjs', // This is needed so `type="module"` works | ||
}, | ||
}, | ||
}, | ||
plugins: [externalizeDepsPlugin()], | ||
define: { | ||
...getClientEnvironmentVariables(), | ||
}, | ||
resolve: { | ||
alias: { | ||
...getAliasesFromTsConfig(), | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
function resolvePathFromProjectRoot(pathSegment: string) { | ||
return resolve(__dirname, pathSegment); | ||
} |
Oops, something went wrong.