import electronfrom"vite-plugin-electron";//https://vitejs.dev/config/exportdefaultdefineConfig({ plugins: [ vue(), electron([ { entry:"electron/main.ts",//preload: {///Shortcut of `build.rollupOptions.input`//input: "electron/preload.ts",//},///Optional: Use Node.js API in the R...
在electron/main.ts 中添加一些代码 importpathfrom'path'import{app,BrowserWindow}from'electron'app.whenReady().then(()=>{constpreload=path.join(__dirname,'preload.js')consthtml=path.join(__dirname,'../index.html')newBrowserWindow({webPreferences:{preload,},}).loadFile(html)}) 在electron/prelo...
安装electron-devtools-installer用于开发调试electron npm install -D electron-devtools-installer 用vite构建electron应用程序需要一个vite插件 npm install -Dvite-plugin-electron 创建项目入口——主进程 electron引入成功了,可以开始写electron的相关代码了,新建一个src-electron文件用来写electron的代码,在它下面创建一个...
Electron的node module并没有提供API给开发者调用以启动进程 所以我们只能通过node的child_process模块来启动Electron的进程 代码如下: 代码语言:javascript 复制 createElectronProcess(){this.electronProcess=spawn(require("electron").toString(),[path.join(this.bundledDir,"entry.js")],{cwd:process.cwd(),env,...
# 安装electron-devtools-installer 用于开发调试electron yarn add-D electron-devtools-installer 到这一步还需要安装一个构建electron程序的vite插件vite-plugin-electron yarn add -D vite-plugin-electron vite-plugin-electron:用于构建electron应用程序的vite插件。仅需少量配置,即可快速整合vite electron开发环境。
开发新版本 Vue 项目推荐你使用 Vite 脚手架构建开发环境,然而 Vite 脚手架更倾向于构建纯 Web 页面,而不是桌面应用,因此开发者要做很多额外的配置和开发工作才能把 Electron 引入到 Vue 项目中,这也是很多开发者都基于开源工具来构建 Electron+Vue 的开发环境的原因。
vite-plugin-electron/dist/index.d.ts Version: 1.7 kBTypeScriptView Raw 1 /// <reference types="node" /> 2 import { type Plugin } from 'vite'; 3 import { resolveViteConfig, withExternalBuiltins } from './utils'; 4 export { resolveViteConfig, withExternalBuiltins, }; ...
import{build,startup}from'vite-plugin-electron'constisDev=process.env.NODE_ENV==='development'constisProd=process.env.NODE_ENV==='production'build({entry:'electron/main.ts',vite:{mode:process.env.NODE_ENV,build:{minify:isProd,watch:isDev?{}:null,},plugins:[{name:'plugin-start-electron',...
vite-plugin-electron/dist/simple.mjs Version: 6.25 kBJavaScriptView Raw 1importfsfrom"node:fs"; 2importpathfrom"node:path"; 3import{ mergeConfig }from"vite"; 4importelectronfrom"./index.mjs"; 5import"node:child_process"; 6import"node:module"; ...