Skip to content

Commit

Permalink
chore: change readme and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgao365 committed Jun 4, 2024
1 parent 9f00c7d commit 063a903
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 26 deletions.
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
# vite-plugin-target
# @tomjs/vite-plugin-target

Make Vite support Electron, Node.js, etc.

[![NPM version](https://img.shields.io/npm/v/vite-plugin-target.svg)](https://npmjs.com/package/vite-plugin-target)
[![NPM Downloads](https://img.shields.io/npm/dm/vite-plugin-target.svg)](https://npmjs.com/package/vite-plugin-target)
[![NPM version](https://img.shields.io/npm/v/@tomjs/vite-plugin-target)](https://npmjs.com/package/@tomjs/vite-plugin-target) ![NPM](https://img.shields.io/npm/l/@tomjs/release-cli)

This library just fixes the types issue of [vite-plugin-target](https://github.com/vite-plugin/vite-plugin-target)

## Install

```sh
npm i -D vite-plugin-target
# pnpm
pnpm add @tomjs/vite-plugin-target -D

# yarn
yarn add @tomjs/vite-plugin-target -D

# npm
npm add @tomjs/vite-plugin-target -D
```

## Examples

- [electron](https://github.com/vite-plugin/vite-plugin-target/tree/main/examples/electron) - with [Vite](https://vitejs.dev/).
- [electron-forge](https://github.com/vite-plugin/vite-plugin-target/tree/main/examples/electron-forge) - with Electron's official [forge](https://www.electronforge.io/) scaffold.
- [vite-electron-plugin](https://github.com/vite-plugin/vite-plugin-target/tree/main/examples/vite-electron-plugin) - with [vite-electron-plugin](https://github.com/electron-vite/vite-electron-plugin).
- [electron](https://github.com/tomjs/vite-plugin-target/tree/main/examples/electron) - with [Vite](https://vitejs.dev/).
- [vite-electron-plugin](https://github.com/tomjs/vite-plugin-target/tree/main/examples/vite-electron-plugin) - with [vite-electron-plugin](https://github.com/electron-vite/vite-electron-plugin).

## Usage

```js
import target from 'vite-plugin-target'
import target from '@tomjs/vite-plugin-target'

// Electron Renderer
export default {
Expand Down Expand Up @@ -68,21 +75,20 @@ export interface NodeOptions {
/**
* Pass to `config.esbuild.target`
*/
version?: string
version?: string;
}

export interface ElectronOptions extends NodeOptions {
nodeIntegration?: boolean
nodeIntegration?: boolean;
}

export type Options =
| { node: NodeOptions }
| { 'electron-main': NodeOptions }
| { 'electron-preload': ElectronOptions }
| { 'electron-renderer': ElectronOptions }
| { 'electron-renderer': ElectronOptions };
```

## How to work?

- For `node` `electron-main` `electron-preload`, the plugin only changes a few preset configurations.
Expand Down
2 changes: 1 addition & 1 deletion examples/electron/main/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import target from 'vite-plugin-target'
import target from '@tomjs/vite-plugin-target'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
4 changes: 2 additions & 2 deletions examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"build": "node build.js && electron-builder"
},
"devDependencies": {
"@tomjs/vite-plugin-target": "workspace:*",
"electron": "^22.2.0",
"electron-builder": "^23.6.0",
"vite": "^4.1.1",
"vite-plugin-target": "workspace:*"
"vite": "^4.1.1"
}
}
2 changes: 1 addition & 1 deletion examples/electron/preload/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import target from 'vite-plugin-target'
import target from '@tomjs/vite-plugin-target'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion examples/electron/renderer/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import target from 'vite-plugin-target'
import target from '@tomjs/vite-plugin-target'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
4 changes: 2 additions & 2 deletions examples/vite-electron-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"build": "vite build && electron-builder"
},
"devDependencies": {
"@tomjs/vite-plugin-target": "workspace:*",
"electron": "^22.2.0",
"electron-builder": "^23.6.0",
"vite": "^4.1.1",
"vite-electron-plugin": "^0.7.4",
"vite-plugin-target": "workspace:*"
"vite-electron-plugin": "^0.7.4"
}
}
2 changes: 1 addition & 1 deletion examples/vite-electron-plugin/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import target from 'vite-plugin-target'
import target from '@tomjs/vite-plugin-target'
import electron from 'vite-electron-plugin'

export default defineConfig({
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 063a903

Please sign in to comment.