Skip to content

Commit 3bf3f20

Browse files
authored
Merge pull request #62 from electron-vite/v0.9.2
V0.9.2
2 parents dd55a90 + 7b08b5e commit 3bf3f20

File tree

11 files changed

+34
-22
lines changed

11 files changed

+34
-22
lines changed

CHANGELOG.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1+
## 0.9.2 (2022-08-29)
2+
3+
*vite-plugin-electron*
4+
5+
- 715a1cd fix(electron): `VITE_DEV_SERVER_HOSTNAME` instead `VITE_DEV_SERVER_HOST`
6+
7+
*vite-plugin-electron-renderer*
8+
19
## 0.9.1 (2022-08-24)
210

3-
#### vite-plugin-electron
11+
*vite-plugin-electron*
412

513
- db61e49 feat(electron): support custom start 🌱 | #57, #58
614

7-
#### vite-plugin-electron-renderer
15+
~~*vite-plugin-electron-renderer*~~
816

917
## 0.9.0 (2022-08-12)
1018

1119
🎉 `v0.9.0` is a stable version based on `[email protected]`
1220

13-
#### vite-plugin-electron
21+
~~*vite-plugin-electron*~~
1422

15-
#### vite-plugin-electron-renderer
23+
*vite-plugin-electron-renderer*
1624

1725
- ebc6a3d chore(electron-renderer): remove `renderBuiltUrl()` based on [email protected] ([[email protected]](https://github.com/vitejs/vite/pull/9381/commits/8f2065efcb6ba664f7dce6f3c7666b29e2c56027#diff-aa53520bfd53e6c24220c44494457cc66370fd2bee513c15f9be7eb537a363e7L874))

packages/electron/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ PR: #51
1818
1. feat: add `VITE_DEV_SERVER_URL` to electron
1919
process env, so that it is easier to use
2020

21-
2. fix(🐞): VITE_DEV_SERVER_HOST cannot be used directly when
22-
VITE_DEV_SERVER_HOST is a ipv6 address or
21+
2. fix(🐞): VITE_DEV_SERVER_HOSTNAME cannot be used directly when
22+
VITE_DEV_SERVER_HOSTNAME is a ipv6 address or
2323
vite config `server.host` is true
2424

2525
3. fix(🐞): use vite config `mode` as default build

packages/electron/electron-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
declare namespace NodeJS {
33
interface ProcessEnv {
44
NODE_ENV: 'development' | 'production'
5-
readonly VITE_DEV_SERVER_HOST: string
5+
readonly VITE_DEV_SERVER_HOSTNAME: string
66
readonly VITE_DEV_SERVER_PORT: string
77
readonly VITE_DEV_SERVER_URL: string
88
}

packages/electron/src/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export function resolveEnv(server: ViteDevServer) {
178178

179179
if (isAddressInfo(addressInfo)) {
180180
const { address, port } = addressInfo
181-
const host = resolveHostname(address)
181+
const hostname = resolveHostname(address)
182182

183183
const options = server.config.server
184184
const protocol = options.https ? 'https' : 'http'
@@ -187,8 +187,8 @@ export function resolveEnv(server: ViteDevServer) {
187187
const path = typeof options.open === 'string' ? options.open : devBase
188188
const url = path.startsWith('http')
189189
? path
190-
: `${protocol}://${host}:${port}${path}`
190+
: `${protocol}://${hostname}:${port}${path}`
191191

192-
return { url, host, port }
192+
return { url, hostname, port }
193193
}
194194
}

packages/electron/src/serve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function bootstrap(config: Configuration, server: ViteDevServer) {
6363
if (env) {
6464
Object.assign(process.env, {
6565
VITE_DEV_SERVER_URL: env.url,
66-
VITE_DEV_SERVER_HOST: env.host,
66+
VITE_DEV_SERVER_HOSTNAME: env.hostname,
6767
VITE_DEV_SERVER_PORT: env.port,
6868
})
6969
}

playground/usecase-in-main/electron-env.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

playground/usecase-in-main/electron/main/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ export const ROOT_PATH = {
1414
let win: BrowserWindow | null = null
1515
// Here, you can also use other preload
1616
const preload = path.join(__dirname, '../preload/index.js')
17-
// 🚧 Use ['ENV_NAME'] avoid vite:define plugin
18-
const url = `http://${process.env['VITE_DEV_SERVER_HOST']}:${process.env['VITE_DEV_SERVER_PORT']}`
17+
const url = process.env.VITE_DEV_SERVER_URL as string
1918
const indexHtml = path.join(ROOT_PATH.dist, 'index.html')
2019

2120
function createWindow() {
22-
win = new BrowserWindow({})
21+
win = new BrowserWindow({
22+
webPreferences: {
23+
preload,
24+
},
25+
})
2326

2427
if (app.isPackaged) {
2528
win.loadFile(indexHtml)

playground/usecase-in-main/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
"noImplicitReturns": true,
1717
"skipLibCheck": true
1818
},
19-
"include": ["src", "electron-env.d.ts", "vite.config.ts"]
19+
"types": [
20+
"vite-plugin-electron/electron-env"
21+
]
2022
}

playground/usecase-in-renderer/electron-env.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

playground/usecase-in-renderer/electron/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ export const ROOT_PATH = {
1313
let win: BrowserWindow | null = null
1414
// Here, you can also use other preload
1515
const preload = path.join(__dirname, 'preload.js')
16-
// 🚧 Use ['ENV_NAME'] avoid vite:define plugin
17-
const url = `http://${process.env['VITE_DEV_SERVER_HOST']}:${process.env['VITE_DEV_SERVER_PORT']}`
16+
const url = process.env.VITE_DEV_SERVER_URL as string
1817
const indexHtml = path.join(ROOT_PATH.dist, 'index.html')
1918

2019
function createWindow() {

0 commit comments

Comments
 (0)