vite-plugin-electron
Advanced tools
Comparing version 0.1.1 to 0.2.0
import type { Configuration } from './types'; | ||
export { electron as default } from './plugin'; | ||
import type { Plugin } from 'vite'; | ||
export { Configuration }; | ||
export declare function defineConfig(config: Configuration): Configuration; | ||
export default function electron(config: Configuration): Plugin[]; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defineConfig = exports.default = void 0; | ||
var plugin_1 = require("./plugin"); | ||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return plugin_1.electron; } }); | ||
exports.defineConfig = void 0; | ||
const renderer_1 = __importDefault(require("../renderer")); | ||
const serve_1 = require("./serve"); | ||
const build_1 = require("./build"); | ||
function defineConfig(config) { | ||
@@ -10,1 +14,26 @@ return config; | ||
exports.defineConfig = defineConfig; | ||
function electron(config) { | ||
const name = 'vite-plugin-electron'; | ||
return [ | ||
{ | ||
name: `${name}:serve`, | ||
apply: 'serve', | ||
configureServer(server) { | ||
const printUrls = server.printUrls; | ||
server.printUrls = function () { | ||
printUrls(); | ||
(0, serve_1.bootstrap)(config, server); | ||
}; | ||
}, | ||
}, | ||
{ | ||
name: `${name}:build`, | ||
apply: 'build', | ||
async configResolved(viteConfig) { | ||
await (0, build_1.build)(config, viteConfig); | ||
}, | ||
}, | ||
...(config.main.nodeIntegration ? (0, renderer_1.default)() : []), | ||
]; | ||
} | ||
exports.default = electron; |
@@ -1,11 +0,12 @@ | ||
import { UserConfigExport, LibraryOptions } from 'vite'; | ||
export interface GeneralConfig { | ||
import type { UserConfigExport, LibraryOptions } from 'vite'; | ||
import type { InputOption } from 'rollup'; | ||
export interface MainConfig { | ||
/** Alias of build.lib.entry */ | ||
entry: LibraryOptions['entry']; | ||
vite?: UserConfigExport; | ||
} | ||
export interface MainConfig extends GeneralConfig { | ||
nodeIntegration?: boolean; | ||
} | ||
export interface PreloadConfig extends GeneralConfig { | ||
export interface PreloadConfig { | ||
entry: InputOption; | ||
vite?: UserConfigExport; | ||
} | ||
@@ -12,0 +13,0 @@ export interface Configuration { |
{ | ||
"name": "vite-plugin-electron", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Integrate Vite and Electron", | ||
"main": "dist/index.js", | ||
"repository": "https://github.com/caoxiemeihao/vite-plugins/tree/main/packages/electron", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/caoxiemeihao/vite-plugin-electron.git" | ||
}, | ||
"author": "草鞋没号 <308487730@qq.com>", | ||
@@ -14,3 +17,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"vite-plugin-electron-renderer": "^0.3.2" | ||
"vite-plugin-optimizer": "^1.3.2" | ||
}, | ||
@@ -25,4 +28,5 @@ "devDependencies": { | ||
"plugin", | ||
"electron" | ||
"electron", | ||
"renderer" | ||
] | ||
} |
@@ -38,1 +38,17 @@ # vite-plugin-electron | ||
``` | ||
--- | ||
If you only need to build the Renderer-process, you can just use the `vite-plugin-electron-renderer` plugin | ||
**renderer/vite.config.ts** | ||
```js | ||
import electronRenderer from 'vite-plugin-electron/renderer' | ||
export default { | ||
plugins: [ | ||
electronRenderer(), | ||
], | ||
} | ||
``` |
import type { Configuration } from './types' | ||
import type { Plugin } from 'vite' | ||
import renderer from '../renderer' | ||
import { bootstrap } from './serve' | ||
import { build } from './build' | ||
export { electron as default } from './plugin' | ||
export { Configuration } | ||
@@ -9,1 +12,27 @@ | ||
} | ||
export default function electron(config: Configuration): Plugin[] { | ||
const name = 'vite-plugin-electron' | ||
return [ | ||
{ | ||
name: `${name}:serve`, | ||
apply: 'serve', | ||
configureServer(server) { | ||
const printUrls = server.printUrls | ||
server.printUrls = function () { | ||
printUrls() | ||
bootstrap(config, server) | ||
} | ||
}, | ||
}, | ||
{ | ||
name: `${name}:build`, | ||
apply: 'build', | ||
async configResolved(viteConfig) { | ||
await build(config, viteConfig) | ||
}, | ||
}, | ||
...(config.main.nodeIntegration ? renderer() : []), | ||
] | ||
} |
@@ -1,17 +0,18 @@ | ||
import { | ||
import type { | ||
UserConfigExport, | ||
LibraryOptions, | ||
} from 'vite' | ||
import type { InputOption } from 'rollup' | ||
export interface GeneralConfig { | ||
export interface MainConfig { | ||
/** Alias of build.lib.entry */ | ||
entry: LibraryOptions['entry'] | ||
vite?: UserConfigExport | ||
} | ||
export interface MainConfig extends GeneralConfig { | ||
nodeIntegration?: boolean | ||
} | ||
export interface PreloadConfig extends GeneralConfig { | ||
export interface PreloadConfig { | ||
// TODO: | ||
entry: InputOption | ||
vite?: UserConfigExport | ||
} | ||
@@ -18,0 +19,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
28748
27
662
54
5
78
0
1
0
15
+ Addedvite-plugin-optimizer@^1.3.2
- Removedvite-plugin-electron-renderer@^0.3.2
- Removedvite-plugin-electron-renderer@0.3.3(transitive)