All Projects → BySlin → umi-plugin-electron-builder

BySlin / umi-plugin-electron-builder

Licence: MIT license
umi的electron插件

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to umi-plugin-electron-builder

umi-react-native
umi preset plugins for react-native
Stars: ✭ 54 (-53.04%)
Mutual labels:  umi, umi-plugin, umijs
umi-plugin-menus
将 umi 生成的 routes 转换成 tree 结构 menus 数据,开发中可直接引入该文件来进行导航菜单的生成
Stars: ✭ 29 (-74.78%)
Mutual labels:  umi, umi-plugin
umi-plugin-mobx
😍 use mobx-state-tree gracefully in umijs.
Stars: ✭ 33 (-71.3%)
Mutual labels:  umi, umi-plugin
umi-plugins
Umi Plugins
Stars: ✭ 14 (-87.83%)
Mutual labels:  umi, umi-plugin
route-utils
umi route utils
Stars: ✭ 32 (-72.17%)
Mutual labels:  umi, umijs
umi-plugin-md
🍚 Markdown(*.md) component plugin for umi.
Stars: ✭ 16 (-86.09%)
Mutual labels:  umi, umi-plugin
daymanage
基于umi3+ts开发的日程管理系统,包括前后端, 前端umi3+ts+dva+ssr, 后端koa。打通微信,手机日历,浏览器提醒。后端见daymanage-server。
Stars: ✭ 28 (-75.65%)
Mutual labels:  umi, umi3
Umi
🌋 Pluggable enterprise-level react application framework.
Stars: ✭ 11,724 (+10094.78%)
Mutual labels:  umi, umijs
pc-Dooring
LowCode, PC Page Maker, PC Editor. Make PC as easy as building blocks. | 让网页制作像搭积木一样简单, 轻松搭建PC页面, Web网站, PC端网站. lowcode(low-code)可视化搭建平台
Stars: ✭ 407 (+253.91%)
Mutual labels:  umi
electron-auto-updater-example
Electron auto updater example
Stars: ✭ 39 (-66.09%)
Mutual labels:  electron-builder
Bilibilivideodownload
PC端下载bilibili视频
Stars: ✭ 223 (+93.91%)
Mutual labels:  electron-builder
desktop
🖥️ Electron code examples for JavaScript Everywhere by Adam Scott, published by O'Reilly Media
Stars: ✭ 30 (-73.91%)
Mutual labels:  electron-builder
Youtube Dl Gui
A cross-platform GUI for youtube-dl made in Electron and node.js
Stars: ✭ 183 (+59.13%)
Mutual labels:  electron-builder
mageri
MAGERI - Assemble, align and call variants for targeted genome re-sequencing with unique molecular identifiers
Stars: ✭ 19 (-83.48%)
Mutual labels:  umi
umi-dva-antd-mobile-starter
Get started with Umi3.js and Ant Design Mobile.
Stars: ✭ 21 (-81.74%)
Mutual labels:  umi
hexen-dll-injector
HEX-EN DLL Injector
Stars: ✭ 20 (-82.61%)
Mutual labels:  electron-builder
Electron Vue
An Electron & Vue.js quick start boilerplate with vue-cli scaffolding, common Vue plugins, electron-packager/electron-builder, unit/e2e testing, vue-devtools, and webpack.
Stars: ✭ 14,610 (+12604.35%)
Mutual labels:  electron-builder
umi-plugin-datahub
umi plugin for integrating macaca-datahub, which is a GUI-style mock tool that can be used to replace umi's built-in mock solution.
Stars: ✭ 21 (-81.74%)
Mutual labels:  umi
toutiao
模仿今日头条,实现 APP 端,Server 端, Web 管理端
Stars: ✭ 17 (-85.22%)
Mutual labels:  umi
simpleCMS
simpleCMS是一款开源cms系统, 主要为个人/团队快速开发博客或者知识共享平台, 类似于hexo, worldpress, 但是他们往往需要复杂的搭建过程, 我们将复杂度降到最低, 并且有详细的部署教程, 你只需要有一台服务器, 就能轻松拥有一个属于你的博客平台.
Stars: ✭ 74 (-35.65%)
Mutual labels:  umi

umi-plugin-electron-builder

本插件提供基于umijs的electron的开发及打包,无需修改项目结构,支持混合项目结构和main+renderer项目结构,仅支持 umijs4

混合项目结构示例 点此访问

main+renderer项目结构示例 点此访问

使用混合项目结构时,插件可自动生成项目文件,使用main+renderer项目结构时,请参考示例修改目录结构

Version

更新日志

umi3请使用2.x版本插件,点此访问

安装

$ pnpm i umi-plugin-electron-builder --save-dev

umi4需要手动启用插件

import { defineConfig } from "umi";

export default defineConfig({
  npmClient: "pnpm",
  plugins: [require.resolve("umi-plugin-electron-builder")],
});

配置完成之后,执行

$ pnpm postinstall

执行以下指令,生成主进程文件 src/main/index.ts

$ pnpm electron:init

默认安装最新版本的 electron

自动在 package.json 增加

{
  scripts: {
    'rebuild-deps': 'electron-builder install-app-deps',
    'electron:init': 'umi electron init',
    'electron:dev': 'umi dev electron',
    'electron:build:win': 'umi build electron --win',
    'electron:build:mac': 'umi build electron --mac',
    'electron:build:linux': 'umi build electron --linux',
  },
  //这里需要修改成你自己的应用名称
  name: 'electron_builder_app',
  version: '0.0.1',
}

Electron 版本降级

你可以手动将 package.json 中的 electron 修改至低版本,插件与 electron 版本无关

开发

$ pnpm electron:dev

调试主进程(VS Code)

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node-terminal",
      "request": "launch",
      "name": "debug electron:dev",
      "command": "yarn electron:dev",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "sourceMapPathOverrides": {
        "webpack://main/./*": "${workspaceFolder}/src/main/*"
      },
      "resolveSourceMapLocations": [
        "${workspaceFolder}/src/.umi/electron/**",
        "${workspaceFolder}/src/renderer/.umi/electron/**"
      ],
      "autoAttachChildProcesses": true
    }
  ]
}

打包

打包路径不能有中文,electron-builder不能跨平台打包,请在对应系统上打包

//windows
$ umi build electron --win
//mac
$ umi build electron --mac
//linux
$ umi build electron --linux
//按平台打包
$ umi build electron --win --ia32    //32位
$ umi build electron --win --x64     //64位
$ umi build electron --win --armv7l  //arm32位
$ umi build electron --win --arm64   //arm64位

使用 node 环境下运行的模块

例:使用 serialport 插件

$ pnpm i serialport @types/serialport

配置 .umirc.ts

import { defineConfig } from 'umi';

export default defineConfig({
  electronBuilder: {
    //可选参数
    buildType: 'vite', //webpack或vite,当编译出现问题,可尝试切换为webpack
    //并行构建,默认关闭,如开启出现问题,请关闭此功能
    parallelBuild: false, //并行构建,开启时主进程和渲染进程同时编译
    mainSrc: 'src/main', //默认主进程目录
    preloadSrc: 'src/preload', //默认preload目录,可选,不需要可删除
    routerMode: 'hash', //路由 hash或memory,仅electron下有效,推荐使用hash
    outputDir: 'dist_electron', //默认打包目录
    externals: ['serialport'], //node原生模块配置,打包之后找不到包也需要配置在这里
    rendererTarget: 'web', //构建目标electron-renderer或web,使用上下文隔离时,必须设置为web
    debugPort: 5858, //主进程调试端口
    //2.1.0新增
    preloadEntry: {
      //默认值 key为preload文件名 值为preload输出文件名
      //输出文件名不能为main.js会和主进程文件名冲突
      //文件名为preload目录下多文件名
      //多级目录时key为xxxx/xxxx.ts
      //使用时输出文件会和主进程在同一目录下 preload: path.join(__dirname, 'preload.js')
      'index.ts': 'preload.js',
    },
    viteConfig(config: InlineConfig, type: ConfigType) {
      //主进程Vite配置
      //配置参考 https://vitejs.dev/config/
      //ConfigType分为main和preload可分别配置
    },
    //通过 webpack-chain 的 API 修改 webpack 配置。
    mainWebpackChain(config: Config, type: ConfigType) {
      //ConfigType分为main和preload可分别配置
      // if (type === 'main') {}
      // if (type === 'preload') {}
    },
    //2.1.10新增 开启自定义主进程日志时
    logProcess(log: string, type: LogType) {
      if (type === 'normal') {
        console.log(log);
      } else if (type === 'error') {
        console.error(log);
      }
    },
    builderOptions: {
      //配置参考 https://www.electron.build/configuration/configuration
      appId: 'com.test.test',
      productName: '测试',
      publish: [
        {
          provider: 'generic',
          url: 'http://localhost/test',
        },
      ],
    }, //electronBuilder参数
  },
  routes: [{ path: '/', component: '@/pages/index' }],
});

在 Electron10 以上使用contextIsolation时 rendererTarget 需要设置成 web

builderOptions参考 Electron Builder

已知问题

esbuild 暂不支持 typescript decorator metadata

Vite 与 typeorm 冲突,typeorm 在主进程无法使用

相关 Issue evanw/esbuild#257

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].