diff --git a/CHANGELOG.md b/CHANGELOG.md index 81878d7..e584547 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 0.28.7 (2024-04-27) + +- b3cf74c chore: cleanup, code format +- 957b144 Merge pull request #233 from kuoruan/feat/config +- c0f2647 feat: inherit more config from base user config + +**Contributors:** + +- [#233](https://github.com/electron-vite/vite-plugin-electron/pull/233)@[kuoruan](https://github.com/kuoruan) + ## 0.28.6 (2024-04-21) - be94383 fix: `ElectronOptions['startup']` definition diff --git a/package.json b/package.json index faafdaa..2a97cd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-electron", - "version": "0.28.6", + "version": "0.28.7", "description": "Electron 🔗 Vite", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 35527dd..6eba63b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,8 @@ import { type Plugin, - build as viteBuild, + type ConfigEnv, type UserConfig, + build as viteBuild, } from 'vite' import { resolveServerUrl, @@ -48,8 +49,8 @@ export function build(options: ElectronOptions) { export default function electron(options: ElectronOptions | ElectronOptions[]): Plugin[] { const optionsArray = Array.isArray(options) ? options : [options] - let mode: string let userConfig: UserConfig + let configEnv: ConfigEnv return [ { @@ -70,9 +71,11 @@ export default function electron(options: ElectronOptions | ElectronOptions[]): options.vite.root ??= server.config.root options.vite.envDir ??= server.config.envDir options.vite.envPrefix ??= server.config.envPrefix + options.vite.build ??= {} options.vite.build.watch ??= {} options.vite.build.minify ??= false + options.vite.plugins ??= [] options.vite.plugins.push( { @@ -107,14 +110,15 @@ export default function electron(options: ElectronOptions | ElectronOptions[]): apply: 'build', config(config, env) { userConfig = config + configEnv = env + // Make sure that Electron can be loaded into the local file using `loadFile` after packaging. config.base ??= './' - mode = env.mode }, async closeBundle() { for (const options of optionsArray) { options.vite ??= {} - options.vite.mode ??= mode + options.vite.mode ??= configEnv.mode options.vite.root ??= userConfig.root options.vite.envDir ??= userConfig.envDir options.vite.envPrefix ??= userConfig.envPrefix