Skip to content

Commit f6dabc3

Browse files
authored
Merge pull request #235 from electron-vite/v0.28.7
V0.28.7
2 parents 957b144 + 2ab8d07 commit f6dabc3

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 0.28.7 (2024-04-27)
2+
3+
- b3cf74c chore: cleanup, code format
4+
- 957b144 Merge pull request #233 from kuoruan/feat/config
5+
- c0f2647 feat: inherit more config from base user config
6+
7+
**Contributors:**
8+
9+
- [#233](https://github.com/electron-vite/vite-plugin-electron/pull/233)@[kuoruan](https://github.com/kuoruan)
10+
111
## 0.28.6 (2024-04-21)
212

313
- be94383 fix: `ElectronOptions['startup']` definition

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-electron",
3-
"version": "0.28.6",
3+
"version": "0.28.7",
44
"description": "Electron 🔗 Vite",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {
22
type Plugin,
3-
build as viteBuild,
3+
type ConfigEnv,
44
type UserConfig,
5+
build as viteBuild,
56
} from 'vite'
67
import {
78
resolveServerUrl,
@@ -48,8 +49,8 @@ export function build(options: ElectronOptions) {
4849

4950
export default function electron(options: ElectronOptions | ElectronOptions[]): Plugin[] {
5051
const optionsArray = Array.isArray(options) ? options : [options]
51-
let mode: string
5252
let userConfig: UserConfig
53+
let configEnv: ConfigEnv
5354

5455
return [
5556
{
@@ -70,9 +71,11 @@ export default function electron(options: ElectronOptions | ElectronOptions[]):
7071
options.vite.root ??= server.config.root
7172
options.vite.envDir ??= server.config.envDir
7273
options.vite.envPrefix ??= server.config.envPrefix
74+
7375
options.vite.build ??= {}
7476
options.vite.build.watch ??= {}
7577
options.vite.build.minify ??= false
78+
7679
options.vite.plugins ??= []
7780
options.vite.plugins.push(
7881
{
@@ -107,14 +110,15 @@ export default function electron(options: ElectronOptions | ElectronOptions[]):
107110
apply: 'build',
108111
config(config, env) {
109112
userConfig = config
113+
configEnv = env
114+
110115
// Make sure that Electron can be loaded into the local file using `loadFile` after packaging.
111116
config.base ??= './'
112-
mode = env.mode
113117
},
114118
async closeBundle() {
115119
for (const options of optionsArray) {
116120
options.vite ??= {}
117-
options.vite.mode ??= mode
121+
options.vite.mode ??= configEnv.mode
118122
options.vite.root ??= userConfig.root
119123
options.vite.envDir ??= userConfig.envDir
120124
options.vite.envPrefix ??= userConfig.envPrefix

0 commit comments

Comments
 (0)