Skip to content

Commit

Permalink
chore: 4.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
BySlin committed May 3, 2023
1 parent 4acaa7c commit 03e5d93
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
## <small>4.0.3(2023-02-05)</small>

1、支持umi 4.0.49

## <small>4.0.4(2023-05-03)</small>

1、支持defineConfig类型提示
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ $ pnpm i serialport @types/serialport

### 配置 .umirc.ts

```javascript
```typescript
import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
import { defineConfig } from 'umi';
import { InlineConfig } from 'vite';

export default defineConfig({
electronBuilder: {
Expand All @@ -153,19 +155,19 @@ export default defineConfig({
//使用时输出文件会和主进程在同一目录下 preload: path.join(__dirname, 'preload.js')
'index.ts': 'preload.js',
},
viteConfig(config: InlineConfig, type: ConfigType) {
viteConfig(config: InlineConfig, type: "main" | "preload") {
//主进程Vite配置
//配置参考 https://vitejs.dev/config/
//ConfigType分为main和preload可分别配置
},
//通过 webpack-chain 的 API 修改 webpack 配置。
mainWebpackChain(config: Config, type: ConfigType) {
mainWebpackChain(config: Config, type: "main" | "preload") {
//ConfigType分为main和preload可分别配置
// if (type === 'main') {}
// if (type === 'preload') {}
},
//2.1.10新增 开启自定义主进程日志时
logProcess(log: string, type: LogType) {
logProcess(log: string, type: "normal" | "error") {
if (type === 'normal') {
console.log(log);
} else if (type === 'error') {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prettier-plugin-organize-imports": "^3.2.1",
"prettier-plugin-packagejson": "^2.3.0",
"typescript": "^4.9.4",
"umi-plugin-electron-builder": "^4.0.0"
"umi-plugin-electron-builder": "^4.0.4"
},
"name": "electron_builder_app",
"version": "0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/main+renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"prettier-plugin-organize-imports": "^3.2.1",
"prettier-plugin-packagejson": "^2.3.0",
"typescript": "^4.9.4",
"umi-plugin-electron-builder": "^4.0.0"
"umi-plugin-electron-builder": "^4.0.4"
}
}
4 changes: 4 additions & 0 deletions lib/compile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
Expand Down
4 changes: 4 additions & 0 deletions lib/compile/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
Expand Down
4 changes: 4 additions & 0 deletions lib/compile/webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
Expand Down
36 changes: 20 additions & 16 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
Expand Down Expand Up @@ -68,22 +72,22 @@ function src_default(api) {
key: "electronBuilder",
config: {
default: defaultConfig,
schema(joi) {
return joi.object({
buildType: joi.string(),
parallelBuild: joi.boolean(),
mainSrc: joi.string(),
preloadSrc: joi.string(),
outputDir: joi.string(),
externals: joi.array(),
builderOptions: joi.object(),
routerMode: joi.string(),
rendererTarget: joi.string(),
debugPort: joi.number(),
preloadEntry: joi.object(),
viteConfig: joi.func(),
mainWebpackChain: joi.func(),
logProcess: joi.func()
schema({ zod }) {
return zod.object({
buildType: zod.enum(["vite", "webpack"]).optional(),
parallelBuild: zod.boolean().optional(),
mainSrc: zod.string().optional(),
preloadSrc: zod.string().optional(),
outputDir: zod.string().optional(),
externals: zod.string().array().optional(),
builderOptions: zod.record(zod.string(), zod.any()).optional(),
routerMode: zod.enum(["hash", "memory", "browser"]).optional(),
rendererTarget: zod.enum(["electron-renderer", "web"]).optional(),
debugPort: zod.number().optional(),
preloadEntry: zod.record(zod.string(), zod.string()).optional(),
viteConfig: zod.function().args(zod.any(), zod.enum(["main", "preload"])).returns(zod.void()).optional(),
mainWebpackChain: zod.function().args(zod.any(), zod.enum(["main", "preload"])).returns(zod.void()).optional(),
logProcess: zod.function().args(zod.string(), zod.enum(["normal", "error"])).returns(zod.void()).optional()
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "umi-plugin-electron-builder",
"version": "4.0.3",
"version": "4.0.4",
"description": "Umi plugin for electron-builder",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
44 changes: 28 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,34 @@ export default function (api: IApi) {
key: 'electronBuilder',
config: {
default: defaultConfig,
schema(joi) {
return joi.object({
buildType: joi.string(),
parallelBuild: joi.boolean(),
mainSrc: joi.string(),
preloadSrc: joi.string(),
outputDir: joi.string(),
externals: joi.array(),
builderOptions: joi.object(),
routerMode: joi.string(),
rendererTarget: joi.string(),
debugPort: joi.number(),
preloadEntry: joi.object(),
viteConfig: joi.func(),
mainWebpackChain: joi.func(),
logProcess: joi.func(),
schema({ zod }) {
return zod.object({
buildType: zod.enum(['vite', 'webpack']).optional(),
parallelBuild: zod.boolean().optional(),
mainSrc: zod.string().optional(),
preloadSrc: zod.string().optional(),
outputDir: zod.string().optional(),
externals: zod.string().array().optional(),
builderOptions: zod.record(zod.string(), zod.any()).optional(),
routerMode: zod.enum(['hash', 'memory', 'browser']).optional(),
rendererTarget: zod.enum(['electron-renderer', 'web']).optional(),
debugPort: zod.number().optional(),
preloadEntry: zod.record(zod.string(), zod.string()).optional(),
viteConfig: zod
.function()
.args(zod.any(), zod.enum(['main', 'preload']))
.returns(zod.void())
.optional(),
mainWebpackChain: zod
.function()
.args(zod.any(), zod.enum(['main', 'preload']))
.returns(zod.void())
.optional(),
logProcess: zod
.function()
.args(zod.string(), zod.enum(['normal', 'error']))
.returns(zod.void())
.optional(),
});
},
},
Expand Down

0 comments on commit 03e5d93

Please sign in to comment.