-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: electron-vite PoC * fix: fix preload path * remove rollup deps and config * fix: debug mode * fix: build mode, asset path * fix: remove unused dependencies * feat: use `executeJavaScriptInIsolatedWorld` instead of `executeJavaScript` * feat: enable `minify` * fix(actions): update task name * fix: fix dev mode check * fix: remove unused variable
- Loading branch information
1 parent
c5d0314
commit 2da29fc
Showing
31 changed files
with
904 additions
and
612 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
.eslintrc.js | ||
rollup.main.config.ts | ||
rollup.preload.config.ts | ||
rollup.renderer.config.ts | ||
electron.vite.config.ts |
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,103 @@ | ||
import { defineConfig, defineViteConfig } from 'electron-vite'; | ||
import builtinModules from 'builtin-modules'; | ||
|
||
import type { UserConfig } from 'vite'; | ||
|
||
export default defineConfig({ | ||
main: defineViteConfig(({ mode }) => { | ||
const commonConfig: UserConfig = { | ||
publicDir: 'assets', | ||
build: { | ||
lib: { | ||
entry: 'src/index.ts', | ||
formats: ['cjs'], | ||
}, | ||
outDir: 'dist/main', | ||
commonjsOptions: { | ||
ignoreDynamicRequires: true, | ||
}, | ||
rollupOptions: { | ||
external: ['electron', 'custom-electron-prompt', ...builtinModules], | ||
input: './src/index.ts', | ||
}, | ||
}, | ||
}; | ||
|
||
if (mode === 'development') { | ||
return commonConfig; | ||
} | ||
|
||
return { | ||
...commonConfig, | ||
build: { | ||
...commonConfig.build, | ||
minify: true, | ||
cssMinify: true, | ||
}, | ||
}; | ||
}), | ||
preload: defineViteConfig(({ mode }) => { | ||
const commonConfig: UserConfig = { | ||
build: { | ||
lib: { | ||
entry: 'src/preload.ts', | ||
formats: ['cjs'], | ||
}, | ||
outDir: 'dist/preload', | ||
commonjsOptions: { | ||
ignoreDynamicRequires: true, | ||
}, | ||
rollupOptions: { | ||
external: ['electron', 'custom-electron-prompt', ...builtinModules], | ||
input: './src/preload.ts', | ||
} | ||
}, | ||
}; | ||
|
||
if (mode === 'development') { | ||
return commonConfig; | ||
} | ||
|
||
return { | ||
...commonConfig, | ||
build: { | ||
...commonConfig.build, | ||
minify: true, | ||
cssMinify: true, | ||
}, | ||
}; | ||
}), | ||
renderer: defineViteConfig(({ mode }) => { | ||
const commonConfig: UserConfig = { | ||
root: './src/', | ||
build: { | ||
lib: { | ||
entry: 'src/index.html', | ||
formats: ['iife'], | ||
name: 'renderer', | ||
}, | ||
outDir: 'dist/renderer', | ||
commonjsOptions: { | ||
ignoreDynamicRequires: true, | ||
}, | ||
rollupOptions: { | ||
external: ['electron', ...builtinModules], | ||
input: './src/index.html', | ||
}, | ||
}, | ||
}; | ||
|
||
if (mode === 'development') { | ||
return commonConfig; | ||
} | ||
|
||
return { | ||
...commonConfig, | ||
build: { | ||
...commonConfig.build, | ||
minify: true, | ||
cssMinify: true, | ||
}, | ||
}; | ||
}), | ||
}); |
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.