diff --git a/README.md b/README.md index 1d55b7c..ef0d60b 100644 --- a/README.md +++ b/README.md @@ -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 { @@ -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. diff --git a/examples/electron/main/vite.config.ts b/examples/electron/main/vite.config.ts index eb5618e..37ef1e8 100644 --- a/examples/electron/main/vite.config.ts +++ b/examples/electron/main/vite.config.ts @@ -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({ diff --git a/examples/electron/package.json b/examples/electron/package.json index 963ec53..6076c1e 100644 --- a/examples/electron/package.json +++ b/examples/electron/package.json @@ -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" } } diff --git a/examples/electron/preload/vite.config.ts b/examples/electron/preload/vite.config.ts index 3d07fbf..a5bbe34 100644 --- a/examples/electron/preload/vite.config.ts +++ b/examples/electron/preload/vite.config.ts @@ -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({ diff --git a/examples/electron/renderer/vite.config.ts b/examples/electron/renderer/vite.config.ts index 01c031c..490a5f8 100644 --- a/examples/electron/renderer/vite.config.ts +++ b/examples/electron/renderer/vite.config.ts @@ -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({ diff --git a/examples/vite-electron-plugin/package.json b/examples/vite-electron-plugin/package.json index 9bf1116..67e599d 100644 --- a/examples/vite-electron-plugin/package.json +++ b/examples/vite-electron-plugin/package.json @@ -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" } } diff --git a/examples/vite-electron-plugin/vite.config.ts b/examples/vite-electron-plugin/vite.config.ts index 61829a3..82cc494 100644 --- a/examples/vite-electron-plugin/vite.config.ts +++ b/examples/vite-electron-plugin/vite.config.ts @@ -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({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 57627ca..ee94d45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,6 +33,9 @@ importers: examples/electron: devDependencies: + '@tomjs/vite-plugin-target': + specifier: workspace:* + version: link:../.. electron: specifier: ^22.2.0 version: 22.3.27 @@ -42,12 +45,12 @@ importers: vite: specifier: ^4.1.1 version: 4.5.3(@types/node@18.19.34) - vite-plugin-target: - specifier: workspace:* - version: link:../.. examples/vite-electron-plugin: devDependencies: + '@tomjs/vite-plugin-target': + specifier: workspace:* + version: link:../.. electron: specifier: ^22.2.0 version: 22.3.27 @@ -60,9 +63,6 @@ importers: vite-electron-plugin: specifier: ^0.7.4 version: 0.7.4(acorn@8.11.3)(esbuild@0.18.20) - vite-plugin-target: - specifier: workspace:* - version: link:../.. packages: