# vite-plugin-electron **Repository Path**: dancingalone/vite-plugin-electron ## Basic Information - **Project Name**: vite-plugin-electron - **Description**: Vite plugin for electron-builder - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 7 - **Created**: 2021-12-10 - **Last Updated**: 2022-04-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
仅需少量配置,即可快速整合vite electron开发环境。1. 默认支持模块热替换(方便开发) 2. 默认支持打包静态资源(图片,视频等) 3. 支持.node模块打包 4. 渲染进程支持node模块 ## 使用 ### 注册插件 vite.config.js: ```js import { defineConfig } from 'vite' import electron from '@xyh19/vite-plugin-electron' export default defineConfig({ plugins: [ electron({ input: { appEntry: 'src/main/app.ts', //app入口 entries: ['src/main/preload.ts'],//preload }, }), ] }) ``` ## 选项声明 ```ts import { PluginOption } from 'vite'; import * as electron_builder from 'electron-builder'; import { RollupCommonJSOptions } from '@rollup/plugin-commonjs'; import { UserOptions as UserOptions$1 } from '@xyh19/rollup-plugin-assets'; import rollup from 'rollup'; import { Options } from 'rollup-plugin-esbuild'; interface UserOptions { input?: { /** * app入口 * @default (__dirname+'../lib/app-entry.js') */ appEntry?: string; /** * 其他入口(preload等) */ entries?: string | string[]; srcRoot?: string; }; output?: { /** * 输出目录 * @default 'dist' */ dir?: string; /** * renderer 输出目录,相对于 output.dir * @default 'renderer' */ rendererDir?: string; /** * Whether to Object.freeze() namespace import objects (i.e. import * as namespaceImportObject from...) that are accessed dynamically. * @default true */ freeze?: boolean; /** * 要在捆绑包中添加/附加的字符串。您还可以提供一个函数,该函数返回解析为字符串的承诺,以异步生成它(注意:横幅和页脚选项不会破坏sourcemaps)。 */ banner?: string | (() => string | Promise