Skip to content

Commit

Permalink
Merge pull request #235 from electron-vite/v0.28.7
Browse files Browse the repository at this point in the history
V0.28.7
  • Loading branch information
caoxiemeihao authored Apr 27, 2024
2 parents 957b144 + 2ab8d07 commit f6dabc3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
type Plugin,
build as viteBuild,
type ConfigEnv,
type UserConfig,
build as viteBuild,
} from 'vite'
import {
resolveServerUrl,
Expand Down Expand Up @@ -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 [
{
Expand All @@ -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(
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f6dabc3

Please sign in to comment.