@tomjs/vite-plugin-electron 1.2.2 → 1.3.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 +64 -1
- package/README.zh_CN.md +64 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +50 -19
- package/dist/index.mjs +51 -20
- package/env.d.ts +4 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -181,7 +181,7 @@ export default defineConfig({
|
|
|
181
181
|
|
|
182
182
|
| Property | Type | Default | Description |
|
|
183
183
|
| --- | --- | --- | --- |
|
|
184
|
-
| recommended | `boolean` | `true` |
|
|
184
|
+
| recommended | `boolean` | `true` | This option is intended to provide recommended default parameters and behavior. |
|
|
185
185
|
| external | `string[]` | | List of modules that should not be bundled. |
|
|
186
186
|
| main | [MainOptions](#MainOptions) | | Configuration options for the electron main process. |
|
|
187
187
|
| preload | [PreloadOptions](#PreloadOptions) | | Configuration options for the electron preload process. |
|
|
@@ -225,3 +225,66 @@ Based on [Options](https://paka.dev/npm/tsup) of [tsup](https://tsup.egoist.dev/
|
|
|
225
225
|
| --------- | ------------------------ | ----------------------- |
|
|
226
226
|
| sourcemap | `true` | `false` |
|
|
227
227
|
| minify | `false` | `true` |
|
|
228
|
+
|
|
229
|
+
## Debug
|
|
230
|
+
|
|
231
|
+
### Web debugging
|
|
232
|
+
|
|
233
|
+
Use [@tomjs/electron-devtools-installer](https://npmjs.com/package/@tomjs/electron-devtools-installer) to install the `Chrome Devtools` plugins and use it like web development
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import { app } from 'electron';
|
|
237
|
+
|
|
238
|
+
app.whenReady().then(() => {
|
|
239
|
+
const { installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = await import(
|
|
240
|
+
'@tomjs/electron-devtools-installer'
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
|
|
244
|
+
.then(exts => {
|
|
245
|
+
console.log(
|
|
246
|
+
'Added Extension: ',
|
|
247
|
+
exts.map(s => s.name),
|
|
248
|
+
);
|
|
249
|
+
})
|
|
250
|
+
.catch(err => {
|
|
251
|
+
console.log('Failed to install extensions');
|
|
252
|
+
console.error(err);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Main thread debugging
|
|
258
|
+
|
|
259
|
+
#### Turn on debugging
|
|
260
|
+
|
|
261
|
+
Start code compilation through the following configuration or `ELECTRON_DEBUG=1 vite dev`
|
|
262
|
+
|
|
263
|
+
- Enable by setting `APP_ELECTRON_DEBUG=1` in `.env` file
|
|
264
|
+
- `vite.config.js` configures `electron({ debug: true })` to be turned on
|
|
265
|
+
|
|
266
|
+
#### VSCODE
|
|
267
|
+
|
|
268
|
+
Run `Debug Main Process` through `vscode` to debug the main thread. For debugging tools, refer to [Official Documentation](https://code.visualstudio.com/docs/editor/debugging)
|
|
269
|
+
|
|
270
|
+
`launch.json` is configured as follows:
|
|
271
|
+
|
|
272
|
+
```json
|
|
273
|
+
{
|
|
274
|
+
"version": "0.2.0",
|
|
275
|
+
"configurations": [
|
|
276
|
+
{
|
|
277
|
+
"name": "Debug Main Process",
|
|
278
|
+
"type": "node",
|
|
279
|
+
"request": "launch",
|
|
280
|
+
"cwd": "${workspaceRoot}",
|
|
281
|
+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
|
282
|
+
"windows": {
|
|
283
|
+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
|
284
|
+
},
|
|
285
|
+
"program": "${workspaceRoot}/dist/main/index.js",
|
|
286
|
+
"envFile": "${workspaceRoot}/node_modules/@tomjs/vite-plugin-electron/debug/.env"
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
```
|
package/README.zh_CN.md
CHANGED
|
@@ -182,7 +182,7 @@ export default defineConfig({
|
|
|
182
182
|
|
|
183
183
|
| 参数名 | 类型 | 默认值 | 说明 |
|
|
184
184
|
| --- | --- | --- | --- |
|
|
185
|
-
| recommended | `boolean` | `true` |
|
|
185
|
+
| recommended | `boolean` | `true` | 这个选项是为了提供推荐的默认参数和行为 |
|
|
186
186
|
| external | `string[]` | | 不打包这些模块 |
|
|
187
187
|
| main | [MainOptions](#MainOptions) | | electron main 进程选项 |
|
|
188
188
|
| preload | [PreloadOptions](#PreloadOptions) | | electron preload 进程选项 |
|
|
@@ -224,3 +224,66 @@ export default defineConfig({
|
|
|
224
224
|
| --------- | -------------- | -------------- |
|
|
225
225
|
| sourcemap | `true` | `false` |
|
|
226
226
|
| minify | `false` | `true` |
|
|
227
|
+
|
|
228
|
+
## 调试
|
|
229
|
+
|
|
230
|
+
### Web调试
|
|
231
|
+
|
|
232
|
+
使用 [@tomjs/electron-devtools-installer](https://npmjs.com/package/@tomjs/electron-devtools-installer) 安装 `Chrome Devtools` 插件后像 Web 开发一样使用
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import { app } from 'electron';
|
|
236
|
+
|
|
237
|
+
app.whenReady().then(() => {
|
|
238
|
+
const { installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = await import(
|
|
239
|
+
'@tomjs/electron-devtools-installer'
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
|
|
243
|
+
.then(exts => {
|
|
244
|
+
console.log(
|
|
245
|
+
'Added Extension: ',
|
|
246
|
+
exts.map(s => s.name),
|
|
247
|
+
);
|
|
248
|
+
})
|
|
249
|
+
.catch(err => {
|
|
250
|
+
console.log('Failed to install extensions');
|
|
251
|
+
console.error(err);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 主线程调试
|
|
257
|
+
|
|
258
|
+
#### 开启调试
|
|
259
|
+
|
|
260
|
+
通过如下配置或者 `ELECTRON_DEBUG=1 vite dev` 启动代码编译
|
|
261
|
+
|
|
262
|
+
- 通过 `.env` 文件设置 `APP_ELECTRON_DEBUG=1` 开启
|
|
263
|
+
- `vite.config.js` 配置 `electron({ debug: true })` 开启
|
|
264
|
+
|
|
265
|
+
#### VSCODE
|
|
266
|
+
|
|
267
|
+
通过 `vscode` 运行 `Debug Main Process` 调试主线程,调试工具参考 [官方文档](https://code.visualstudio.com/docs/editor/debugging)
|
|
268
|
+
|
|
269
|
+
`launch.json` 配置如下:
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"version": "0.2.0",
|
|
274
|
+
"configurations": [
|
|
275
|
+
{
|
|
276
|
+
"name": "Debug Main Process",
|
|
277
|
+
"type": "node",
|
|
278
|
+
"request": "launch",
|
|
279
|
+
"cwd": "${workspaceRoot}",
|
|
280
|
+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
|
281
|
+
"windows": {
|
|
282
|
+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
|
283
|
+
},
|
|
284
|
+
"program": "${workspaceRoot}/dist/main/index.js",
|
|
285
|
+
"envFile": "${workspaceRoot}/node_modules/@tomjs/vite-plugin-electron/debug/.env"
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -74,10 +74,10 @@ interface PluginOptions {
|
|
|
74
74
|
*/
|
|
75
75
|
preload?: PreloadOptions;
|
|
76
76
|
/**
|
|
77
|
-
* electron
|
|
78
|
-
* @default
|
|
77
|
+
* electron debug mode, don't startup electron. You can also use `process.env.APP_ELECTRON_DEBUG`. Default is false.
|
|
78
|
+
* @default false
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
debug?: boolean;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
declare function vitePluginElectron(options?: PluginOptions): Plugin;
|
package/dist/index.d.ts
CHANGED
|
@@ -74,10 +74,10 @@ interface PluginOptions {
|
|
|
74
74
|
*/
|
|
75
75
|
preload?: PreloadOptions;
|
|
76
76
|
/**
|
|
77
|
-
* electron
|
|
78
|
-
* @default
|
|
77
|
+
* electron debug mode, don't startup electron. You can also use `process.env.APP_ELECTRON_DEBUG`. Default is false.
|
|
78
|
+
* @default false
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
debug?: boolean;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
declare function vitePluginElectron(options?: PluginOptions): Plugin;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/index.ts
|
|
2
2
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
3
|
+
var _process = require('process');
|
|
3
4
|
var _lodashclonedeep = require('lodash.clonedeep'); var _lodashclonedeep2 = _interopRequireDefault(_lodashclonedeep);
|
|
4
5
|
var _lodashmerge = require('lodash.merge'); var _lodashmerge2 = _interopRequireDefault(_lodashmerge);
|
|
5
6
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
@@ -69,10 +70,11 @@ function getBuildOptions(options) {
|
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
async function startup(options) {
|
|
73
|
+
if (options.debug) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
72
76
|
await startup.exit();
|
|
73
|
-
|
|
74
|
-
options.inspect && args.push("--inspect");
|
|
75
|
-
process.electronApp = _child_process.spawn.call(void 0, _electron2.default, [".", ...args], {
|
|
77
|
+
process.electronApp = _child_process.spawn.call(void 0, _electron2.default, ["."], {
|
|
76
78
|
stdio: "inherit"
|
|
77
79
|
});
|
|
78
80
|
process.electronApp.once("exit", process.exit);
|
|
@@ -97,9 +99,10 @@ startup.exit = async () => {
|
|
|
97
99
|
});
|
|
98
100
|
};
|
|
99
101
|
async function runServe(options, server) {
|
|
102
|
+
options.debug && logger.warn(`debug mode`);
|
|
100
103
|
const buildOptions = getBuildOptions(options);
|
|
104
|
+
const buildCounts = [0, buildOptions.length > 1 ? 0 : 1];
|
|
101
105
|
for (let i = 0; i < buildOptions.length; i++) {
|
|
102
|
-
let isFirstBuild = true;
|
|
103
106
|
const tsOpts = buildOptions[i];
|
|
104
107
|
const { __NAME__: name, onSuccess: _onSuccess, watch, ...tsupOptions } = tsOpts;
|
|
105
108
|
logger.info(`${name} build`);
|
|
@@ -107,16 +110,21 @@ async function runServe(options, server) {
|
|
|
107
110
|
if (typeof _onSuccess === "function") {
|
|
108
111
|
await _onSuccess();
|
|
109
112
|
}
|
|
110
|
-
if (
|
|
113
|
+
if (buildCounts[i] <= 0) {
|
|
114
|
+
buildCounts[i]++;
|
|
111
115
|
logger.info(`${name} build succeeded`);
|
|
112
|
-
|
|
116
|
+
if (buildCounts[0] == 1 && buildCounts[1] == 1) {
|
|
117
|
+
logger.info("electron startup");
|
|
118
|
+
await startup(options);
|
|
119
|
+
}
|
|
113
120
|
return;
|
|
114
121
|
}
|
|
115
122
|
logger.success(`${name} rebuild succeeded!`);
|
|
116
123
|
if (name === "main") {
|
|
117
|
-
|
|
124
|
+
logger.info("electron restart");
|
|
118
125
|
await startup(options);
|
|
119
126
|
} else {
|
|
127
|
+
logger.info("page reload");
|
|
120
128
|
server.ws.send({
|
|
121
129
|
type: "full-reload"
|
|
122
130
|
});
|
|
@@ -124,7 +132,6 @@ async function runServe(options, server) {
|
|
|
124
132
|
};
|
|
125
133
|
await _tsup.build.call(void 0, { onSuccess, watch: true, ...tsupOptions });
|
|
126
134
|
}
|
|
127
|
-
await startup(options);
|
|
128
135
|
}
|
|
129
136
|
async function runBuild(options) {
|
|
130
137
|
const buildOptions = getBuildOptions(options);
|
|
@@ -219,32 +226,56 @@ function vitePluginElectron(options) {
|
|
|
219
226
|
opts.preload.outDir ||= _path2.default.join("dist-electron", "preload");
|
|
220
227
|
}
|
|
221
228
|
if (isDev) {
|
|
222
|
-
opts.main.sourcemap ??=
|
|
223
|
-
opts.preload.sourcemap ??=
|
|
229
|
+
opts.main.sourcemap ??= "inline";
|
|
230
|
+
opts.preload.sourcemap ??= "inline";
|
|
224
231
|
} else {
|
|
225
232
|
opts.main.minify ??= true;
|
|
226
233
|
opts.preload.minify ??= true;
|
|
227
234
|
}
|
|
235
|
+
let envPrefix = config.envPrefix;
|
|
236
|
+
if (!envPrefix) {
|
|
237
|
+
envPrefix = ["VITE_"];
|
|
238
|
+
} else if (typeof envPrefix === "string") {
|
|
239
|
+
envPrefix = [envPrefix];
|
|
240
|
+
}
|
|
241
|
+
if (!envPrefix.includes("APP_")) {
|
|
242
|
+
envPrefix.push("APP_");
|
|
243
|
+
}
|
|
228
244
|
return {
|
|
245
|
+
envPrefix: [...new Set(envPrefix)],
|
|
229
246
|
build: {
|
|
230
247
|
outDir
|
|
231
248
|
}
|
|
232
249
|
};
|
|
233
250
|
},
|
|
251
|
+
configResolved(config) {
|
|
252
|
+
opts.debug = config.env.APP_ELECTRON_DEBUG ? !!config.env.APP_ELECTRON_DEBUG : opts.debug;
|
|
253
|
+
},
|
|
234
254
|
configureServer(server) {
|
|
235
|
-
if (!
|
|
255
|
+
if (!server || !server.httpServer) {
|
|
236
256
|
return;
|
|
237
257
|
}
|
|
238
258
|
server.httpServer.on("listening", async () => {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
259
|
+
var _a;
|
|
260
|
+
const serve = (_a = server.httpServer) == null ? void 0 : _a.address();
|
|
261
|
+
const { address, port, family } = serve;
|
|
262
|
+
const hostname = family === "IPv6" ? `[${address}]` : address;
|
|
263
|
+
const protocol = server.config.server.https ? "https" : "http";
|
|
264
|
+
process.env.APP_DEV_SERVER_URL = `${protocol}://${hostname}:${port}`;
|
|
265
|
+
const DEBUG_PATH = _path2.default.resolve(
|
|
266
|
+
_process.cwd.call(void 0, ),
|
|
267
|
+
"node_modules",
|
|
268
|
+
"@tomjs",
|
|
269
|
+
"vite-plugin-electron",
|
|
270
|
+
"debug"
|
|
271
|
+
);
|
|
272
|
+
if (!_fs2.default.existsSync(DEBUG_PATH)) {
|
|
273
|
+
_fs.mkdirSync.call(void 0, DEBUG_PATH, { recursive: true });
|
|
247
274
|
}
|
|
275
|
+
const env = Object.keys(process.env).filter((s) => s.startsWith("APP_") || s.startsWith("VITE_")).map((s) => `${s}=${process.env[s]}`).join("\n");
|
|
276
|
+
_fs.writeFileSync.call(void 0, _path2.default.join(DEBUG_PATH, ".env"), `NODE_ENV=development
|
|
277
|
+
${env}`);
|
|
278
|
+
console.log("Server is running");
|
|
248
279
|
await runServe(opts, server);
|
|
249
280
|
});
|
|
250
281
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import fs2 from "fs";
|
|
2
|
+
import fs2, { mkdirSync, writeFileSync } from "fs";
|
|
3
|
+
import { cwd } from "process";
|
|
3
4
|
import cloneDeep from "lodash.clonedeep";
|
|
4
5
|
import merge from "lodash.merge";
|
|
5
6
|
import path from "path";
|
|
@@ -69,10 +70,11 @@ function getBuildOptions(options) {
|
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
async function startup(options) {
|
|
73
|
+
if (options.debug) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
72
76
|
await startup.exit();
|
|
73
|
-
|
|
74
|
-
options.inspect && args.push("--inspect");
|
|
75
|
-
process.electronApp = spawn(electron, [".", ...args], {
|
|
77
|
+
process.electronApp = spawn(electron, ["."], {
|
|
76
78
|
stdio: "inherit"
|
|
77
79
|
});
|
|
78
80
|
process.electronApp.once("exit", process.exit);
|
|
@@ -97,9 +99,10 @@ startup.exit = async () => {
|
|
|
97
99
|
});
|
|
98
100
|
};
|
|
99
101
|
async function runServe(options, server) {
|
|
102
|
+
options.debug && logger.warn(`debug mode`);
|
|
100
103
|
const buildOptions = getBuildOptions(options);
|
|
104
|
+
const buildCounts = [0, buildOptions.length > 1 ? 0 : 1];
|
|
101
105
|
for (let i = 0; i < buildOptions.length; i++) {
|
|
102
|
-
let isFirstBuild = true;
|
|
103
106
|
const tsOpts = buildOptions[i];
|
|
104
107
|
const { __NAME__: name, onSuccess: _onSuccess, watch, ...tsupOptions } = tsOpts;
|
|
105
108
|
logger.info(`${name} build`);
|
|
@@ -107,16 +110,21 @@ async function runServe(options, server) {
|
|
|
107
110
|
if (typeof _onSuccess === "function") {
|
|
108
111
|
await _onSuccess();
|
|
109
112
|
}
|
|
110
|
-
if (
|
|
113
|
+
if (buildCounts[i] <= 0) {
|
|
114
|
+
buildCounts[i]++;
|
|
111
115
|
logger.info(`${name} build succeeded`);
|
|
112
|
-
|
|
116
|
+
if (buildCounts[0] == 1 && buildCounts[1] == 1) {
|
|
117
|
+
logger.info("electron startup");
|
|
118
|
+
await startup(options);
|
|
119
|
+
}
|
|
113
120
|
return;
|
|
114
121
|
}
|
|
115
122
|
logger.success(`${name} rebuild succeeded!`);
|
|
116
123
|
if (name === "main") {
|
|
117
|
-
|
|
124
|
+
logger.info("electron restart");
|
|
118
125
|
await startup(options);
|
|
119
126
|
} else {
|
|
127
|
+
logger.info("page reload");
|
|
120
128
|
server.ws.send({
|
|
121
129
|
type: "full-reload"
|
|
122
130
|
});
|
|
@@ -124,7 +132,6 @@ async function runServe(options, server) {
|
|
|
124
132
|
};
|
|
125
133
|
await tsupBuild({ onSuccess, watch: true, ...tsupOptions });
|
|
126
134
|
}
|
|
127
|
-
await startup(options);
|
|
128
135
|
}
|
|
129
136
|
async function runBuild(options) {
|
|
130
137
|
const buildOptions = getBuildOptions(options);
|
|
@@ -218,32 +225,56 @@ function vitePluginElectron(options) {
|
|
|
218
225
|
opts.preload.outDir ||= path.join("dist-electron", "preload");
|
|
219
226
|
}
|
|
220
227
|
if (isDev) {
|
|
221
|
-
opts.main.sourcemap ??=
|
|
222
|
-
opts.preload.sourcemap ??=
|
|
228
|
+
opts.main.sourcemap ??= "inline";
|
|
229
|
+
opts.preload.sourcemap ??= "inline";
|
|
223
230
|
} else {
|
|
224
231
|
opts.main.minify ??= true;
|
|
225
232
|
opts.preload.minify ??= true;
|
|
226
233
|
}
|
|
234
|
+
let envPrefix = config.envPrefix;
|
|
235
|
+
if (!envPrefix) {
|
|
236
|
+
envPrefix = ["VITE_"];
|
|
237
|
+
} else if (typeof envPrefix === "string") {
|
|
238
|
+
envPrefix = [envPrefix];
|
|
239
|
+
}
|
|
240
|
+
if (!envPrefix.includes("APP_")) {
|
|
241
|
+
envPrefix.push("APP_");
|
|
242
|
+
}
|
|
227
243
|
return {
|
|
244
|
+
envPrefix: [...new Set(envPrefix)],
|
|
228
245
|
build: {
|
|
229
246
|
outDir
|
|
230
247
|
}
|
|
231
248
|
};
|
|
232
249
|
},
|
|
250
|
+
configResolved(config) {
|
|
251
|
+
opts.debug = config.env.APP_ELECTRON_DEBUG ? !!config.env.APP_ELECTRON_DEBUG : opts.debug;
|
|
252
|
+
},
|
|
233
253
|
configureServer(server) {
|
|
234
|
-
if (!
|
|
254
|
+
if (!server || !server.httpServer) {
|
|
235
255
|
return;
|
|
236
256
|
}
|
|
237
257
|
server.httpServer.on("listening", async () => {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
258
|
+
var _a;
|
|
259
|
+
const serve = (_a = server.httpServer) == null ? void 0 : _a.address();
|
|
260
|
+
const { address, port, family } = serve;
|
|
261
|
+
const hostname = family === "IPv6" ? `[${address}]` : address;
|
|
262
|
+
const protocol = server.config.server.https ? "https" : "http";
|
|
263
|
+
process.env.APP_DEV_SERVER_URL = `${protocol}://${hostname}:${port}`;
|
|
264
|
+
const DEBUG_PATH = path.resolve(
|
|
265
|
+
cwd(),
|
|
266
|
+
"node_modules",
|
|
267
|
+
"@tomjs",
|
|
268
|
+
"vite-plugin-electron",
|
|
269
|
+
"debug"
|
|
270
|
+
);
|
|
271
|
+
if (!fs2.existsSync(DEBUG_PATH)) {
|
|
272
|
+
mkdirSync(DEBUG_PATH, { recursive: true });
|
|
246
273
|
}
|
|
274
|
+
const env = Object.keys(process.env).filter((s) => s.startsWith("APP_") || s.startsWith("VITE_")).map((s) => `${s}=${process.env[s]}`).join("\n");
|
|
275
|
+
writeFileSync(path.join(DEBUG_PATH, ".env"), `NODE_ENV=development
|
|
276
|
+
${env}`);
|
|
277
|
+
console.log("Server is running");
|
|
247
278
|
await runServe(opts, server);
|
|
248
279
|
});
|
|
249
280
|
},
|
package/env.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/vite-plugin-electron",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A simple vite plugin for electron, supports esm/cjs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
7
7
|
"plugin",
|
|
8
8
|
"electron",
|
|
9
|
-
"tsup"
|
|
9
|
+
"tsup",
|
|
10
|
+
"esm",
|
|
11
|
+
"cjs"
|
|
10
12
|
],
|
|
11
13
|
"author": {
|
|
12
14
|
"name": "Tom Gao",
|