@tomjs/vite-plugin-electron 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/README.zh_CN.md +3 -2
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +4 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -256,6 +256,8 @@ When `recommended` and `builder.enable` are both `true`, use [electron-builder](
|
|
|
256
256
|
- In the `build.outDir` directory configured in vite, generate a new package.json based on the configuration and package.json, excluding non-dependencies.
|
|
257
257
|
- Execute `npm install` and then package.
|
|
258
258
|
|
|
259
|
+
Reference [vite-plugin-electron-renderer](https://github.com/electron-vite/vite-plugin-electron-renderer) and [Two package.json Structure](https://www.electron.build/tutorials/two-package-structure)
|
|
260
|
+
|
|
259
261
|
_Not suitable for everyone._
|
|
260
262
|
|
|
261
263
|
To use this function, you need to install additional `electron-builder`
|
package/README.zh_CN.md
CHANGED
|
@@ -252,8 +252,9 @@ export default defineConfig({
|
|
|
252
252
|
|
|
253
253
|
当 `recommended` 和 `builder.enable` 都为 `true` 时,使用 [electron-builder](https://www.electron.build) 打包 Electron 应用程序。
|
|
254
254
|
|
|
255
|
-
- 在vite中配置的`build.outDir`目录中,根据配置和package.json生成新的package.json
|
|
256
|
-
|
|
255
|
+
- 在vite中配置的`build.outDir`目录中,根据配置和package.json生成新的package.json。
|
|
256
|
+
|
|
257
|
+
参考 [vite-plugin-electron-renderer](https://github.com/electron-vite/vite-plugin-electron-renderer) 和 [Two package.json Structure](https://www.electron.build/tutorials/two-package-structure)
|
|
257
258
|
|
|
258
259
|
_不适合所有人使用。_
|
|
259
260
|
|
package/dist/index.d.mts
CHANGED
|
@@ -91,11 +91,6 @@ interface PluginOptions {
|
|
|
91
91
|
* @default true
|
|
92
92
|
*/
|
|
93
93
|
recommended?: boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Don't bundle these modules, but dependencies and peerDependencies in your package.json are always excluded. [See more](https://tsup.egoist.dev/#excluding-packages)
|
|
96
|
-
* @see https://tsup.egoist.dev/#excluding-packages
|
|
97
|
-
*/
|
|
98
|
-
external?: (string | RegExp)[];
|
|
99
94
|
/**
|
|
100
95
|
* electron main process options
|
|
101
96
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import path from "node:path";
|
|
|
4
4
|
import cloneDeep from "lodash.clonedeep";
|
|
5
5
|
import merge from "lodash.merge";
|
|
6
6
|
import os from "node:os";
|
|
7
|
-
import { cwd } from "node:process";
|
|
8
7
|
import { execa, execaSync } from "execa";
|
|
9
8
|
import { createLogger } from "vite";
|
|
10
9
|
import cp, { spawn } from "node:child_process";
|
|
@@ -175,12 +174,12 @@ function createPkg(options, resolvedConfig) {
|
|
|
175
174
|
} else main = `main/index.${options?.main?.format === "esm" ? "" : "m"}js`;
|
|
176
175
|
const newPkg = {
|
|
177
176
|
name: pkg.name,
|
|
177
|
+
productName: pkg.productName,
|
|
178
178
|
version: pkg.version,
|
|
179
179
|
description: pkg.description,
|
|
180
180
|
type: pkg.type || "commonjs",
|
|
181
|
-
author: getAuthor(pkg.author),
|
|
182
|
-
main
|
|
183
|
-
dependencies: getDeps()
|
|
181
|
+
author: pkg.author || getAuthor(pkg.author),
|
|
182
|
+
main
|
|
184
183
|
};
|
|
185
184
|
writeJson(path.join(outDir, "package.json"), newPkg);
|
|
186
185
|
function getAuthor(author) {
|
|
@@ -194,33 +193,12 @@ function createPkg(options, resolvedConfig) {
|
|
|
194
193
|
}
|
|
195
194
|
return uname;
|
|
196
195
|
}
|
|
197
|
-
function checkDepName(rules, name) {
|
|
198
|
-
return !!rules.find((s) => {
|
|
199
|
-
if (typeof s === "string") return s.includes(name);
|
|
200
|
-
else return s.test(name);
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
function getDeps() {
|
|
204
|
-
const deps = pkg.dependencies || {};
|
|
205
|
-
const newDeps = {};
|
|
206
|
-
Object.keys(deps).forEach((name) => {
|
|
207
|
-
if (checkDepName(externals, name)) newDeps[name] = deps[name];
|
|
208
|
-
});
|
|
209
|
-
return newDeps;
|
|
210
|
-
}
|
|
211
196
|
return newPkg;
|
|
212
197
|
}
|
|
213
198
|
async function runElectronBuilder(options, resolvedConfig) {
|
|
214
199
|
if (typeof options.builder == "boolean" && options.builder === false) return;
|
|
215
|
-
logger.info("building electron app...");
|
|
216
|
-
const DIST_PATH = path.join(cwd(), path.dirname(resolvedConfig.build.outDir));
|
|
217
200
|
createPkg(options, resolvedConfig);
|
|
218
|
-
logger.info(`
|
|
219
|
-
execaSync(`npm install --emit=dev`, {
|
|
220
|
-
cwd: DIST_PATH,
|
|
221
|
-
shell: true
|
|
222
|
-
});
|
|
223
|
-
logger.info(`run electron-builder to package app`);
|
|
201
|
+
logger.info(`created package.json`);
|
|
224
202
|
const config = getBuilderConfig(options, resolvedConfig);
|
|
225
203
|
const { build: build$1 } = await import("electron-builder");
|
|
226
204
|
await build$1({ config });
|
package/package.json
CHANGED