-
-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tech] Move to the
electron-vite
build tool (#3218)
* Move to electron-vite * Declare Vite-related types properly * Remove Fontsource alias We only use this two times, it's easier to just use the proper path there * Adapt E2E tests to new structure * Update to Vite 5 * Update vite & vite-plugin-svgr * Fix build on Windows * Use `path.resolve` to find `index.html` This feels a bit more clear than a "random" starting / * Remove check-disk-space from deps array
- Loading branch information
Showing
27 changed files
with
965 additions
and
466 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,75 @@ | ||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite' | ||
import react from '@vitejs/plugin-react-swc' | ||
import svgr from 'vite-plugin-svgr' | ||
import path from 'path' | ||
|
||
import type { Plugin } from 'vite' | ||
|
||
const srcAliases = ['backend', 'frontend', 'common'].map((aliasName) => ({ | ||
find: aliasName, | ||
replacement: path.join(__dirname, 'src', aliasName) | ||
})) | ||
|
||
const dependenciesToNotExternalize = [ | ||
'@xhmikosr/decompress', | ||
'@xhmikosr/decompress-targz' | ||
] | ||
|
||
// FIXME: Potentially publish this as a dedicated plugin, if other projects | ||
// run into the same issue | ||
const vite_plugin_react_dev_tools: Plugin = { | ||
name: 'react-dev-tools-replace', | ||
transformIndexHtml: { | ||
handler: (html) => | ||
html.replace( | ||
'<!-- REACT_DEVTOOLS_SCRIPT -->', | ||
'<script src="http://localhost:8097"></script>' | ||
) | ||
} | ||
} | ||
|
||
export default defineConfig(({ mode }) => ({ | ||
main: { | ||
build: { | ||
rollupOptions: { | ||
input: 'src/backend/main.ts' | ||
}, | ||
outDir: 'build/main', | ||
minify: mode === 'production', | ||
sourcemap: mode === 'development' ? 'inline' : false | ||
}, | ||
resolve: { alias: srcAliases }, | ||
plugins: [externalizeDepsPlugin({ exclude: dependenciesToNotExternalize })] | ||
}, | ||
preload: { | ||
build: { | ||
rollupOptions: { | ||
input: 'src/backend/preload.ts' | ||
}, | ||
outDir: 'build/preload', | ||
minify: mode === 'production', | ||
sourcemap: mode === 'development' ? 'inline' : false | ||
}, | ||
resolve: { alias: srcAliases }, | ||
plugins: [externalizeDepsPlugin({ exclude: dependenciesToNotExternalize })] | ||
}, | ||
renderer: { | ||
root: '.', | ||
build: { | ||
rollupOptions: { | ||
input: path.resolve('index.html') | ||
}, | ||
target: 'esnext', | ||
outDir: 'build', | ||
emptyOutDir: false, | ||
minify: mode === 'production', | ||
sourcemap: mode === 'development' ? 'inline' : false | ||
}, | ||
resolve: { alias: srcAliases }, | ||
plugins: [ | ||
react(), | ||
svgr(), | ||
mode !== 'production' && vite_plugin_react_dev_tools | ||
] | ||
} | ||
})) |
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
Oops, something went wrong.