Skip to content

Commit

Permalink
Merge pull request #34 from caoxiemeihao/v0.5.0
Browse files Browse the repository at this point in the history
V0.5.0
  • Loading branch information
caoxiemeihao authored May 21, 2023
2 parents 7e2579f + 0c02159 commit a7a2839
Show file tree
Hide file tree
Showing 8 changed files with 2,155 additions and 930 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.5.0 (2023-05-21)

- da27f13 refactor(v0.5.0): `vite-electron-plugin` -> `vite-electron-plugin`
- 7e2579f chore: use pnpm8
- 0480ae5 chore(examples): update quick-start
- f782031 fix: `router` into `options.disableDefaultOptions`

## 0.4.5 (2023-03-30)

- a521612 chore: cleanup
Expand Down
70 changes: 42 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,38 @@
## Features

- 🚀 High-performance <sub><sup>(Not Bundle, based on esbuild)</sup></sub>
- 📦 Out of the box
- 🔥 Hot restart
- 🔥 Hot restart <sub><sup>(Main process)</sup></sub>
- 🚀 Hot reload <sub><sup>(Preload script)</sup></sub>

## Quick Setup

1. Add the following dependency to your project

```sh
# Using pnpm
pnpm add -D nuxt-electron vite-electron-plugin vite-plugin-electron-renderer electron electron-builder
pnpm add -D nuxt-electron vite-plugin-electron vite-plugin-electron-renderer electron electron-builder

# Using yarn
yarn add --dev nuxt-electron vite-electron-plugin vite-plugin-electron-renderer electron electron-builder
yarn add --dev nuxt-electron vite-plugin-electron vite-plugin-electron-renderer electron electron-builder

# Using npm
npm install --save-dev nuxt-electron vite-electron-plugin vite-plugin-electron-renderer electron electron-builder
npm install --save-dev nuxt-electron vite-plugin-electron vite-plugin-electron-renderer electron electron-builder
```

2. Add `nuxt-electron` to the `modules` section of `nuxt.config.ts`

```ts
export default defineNuxtConfig({
modules: [
'nuxt-electron',
],
modules: ['nuxt-electron'],
electron: {
build: [
{
// Main-Process entry file of the Electron App.
entry: 'electron/main.ts',
},
],
},
})
```

Expand All @@ -63,35 +69,39 @@ That's it! You can now use Electron in your Nuxt app ✨

## Electron Options

Here is the default `electron` options

```ts
export default defineNuxtConfig({
modules: [
'nuxt-electron',
],
electron: {
include: ['electron'],
outDir: 'dist-electron',
},
})
```

Full types definition

> This is based on the `vite-electron-plugin`, see the **[Documents](https://github.com/electron-vite/vite-electron-plugin#configuration)** for more detailed options
> This is based on the `vite-plugin-electron`, see the **[Documents](https://github.com/electron-vite/vite-plugin-electron)** for more detailed options
```ts
import type { Configuration } from 'vite-electron-plugin'

export interface ElectronOptions extends Partial<Configuration> {
export interface ElectronOptions {
/**
* `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
*
* @example
*
* ```js
* export default defineNuxtConfig({
* modules: ['nuxt-electron'],
* electron: {
* build: [
* {
* // Main-Process entry file of the Electron App.
* entry: 'electron/main.ts',
* },
* ],
* },
* })
* ```
*/
build: import('vite-plugin-electron').Configuration[],
/**
* @see https://github.com/electron-vite/vite-plugin-electron-renderer
*/
renderer?: Parameters<typeof import('vite-plugin-electron-renderer').default>[0]
/**
* nuxt-electron will modify some options by default
*
* @defaultValue
*
* ```js
* export default defineNuxtConfig({
* ssr: false,
Expand Down Expand Up @@ -150,3 +160,7 @@ If you want to fully customize the default behavior, you can disable it by `disa

[license-src]: https://img.shields.io/npm/l/nuxt-electron.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/nuxt-electron

## TODO

- [ ] write test
18 changes: 15 additions & 3 deletions examples/quick-start/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
export default defineNuxtConfig({
modules: [
'nuxt-electron',
],
modules: ['nuxt-electron'],
electron: {
build: [
{
// Main-Process entry file of the Electron App.
entry: 'electron/main.ts',
},
{
entry: 'electron/preload.ts',
onstart(options) {
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
// instead of restarting the entire Electron App.
options.reload()
},
},
],
renderer: {},
},
})
4 changes: 2 additions & 2 deletions examples/quick-start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
},
"dependencies": {},
"devDependencies": {
"electron": "^23.1.1",
"electron": "^24.3.1",
"electron-builder": "^23.6.0",
"nuxt": "^3.2.2",
"nuxt": "^3.5.0",
"nuxt-electron": "workspace:*"
}
}
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-electron",
"version": "0.4.5",
"version": "0.5.0",
"description": "Nuxt Integration with Electron",
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
Expand All @@ -25,26 +25,23 @@
"prepublishOnly": "npm run build"
},
"peerDependencies": {
"esbuild": "*",
"vite-electron-plugin": "*",
"vite-plugin-electron": "*",
"vite-plugin-electron-renderer": "*"
},
"peerDependenciesMeta": {
"esbuild": {
"optional": true
},
"vite-plugin-electron-renderer": {
"optional": true
}
},
"devDependencies": {
"@types/node": "^18.15.11",
"esbuild": "^0.17.14",
"electron": "^24.3.1",
"nuxt": "^3.2.2",
"typescript": "^4.9.5",
"vite": "^4.1.4",
"vite-electron-plugin": "latest",
"vite-plugin-electron-renderer": "latest"
"vite-plugin-electron": "^0.11.2",
"vite-plugin-electron-renderer": "^0.14.4"
},
"files": [
"electron-env.d.ts",
Expand Down
Loading

0 comments on commit a7a2839

Please sign in to comment.