build: optimize release app workflow (#2011)

This commit is contained in:
Peng Xiao
2023-04-18 17:50:29 +08:00
committed by GitHub
parent f6fb049ff2
commit f36d415c3d
8 changed files with 96 additions and 147 deletions

View File

@@ -1,13 +1,5 @@
import fs from 'node:fs';
import path from 'node:path';
import * as url from 'node:url';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const { node } = JSON.parse(
fs.readFileSync(
path.join(__dirname, '../electron-vendors.autogen.json'),
'utf-8'
)
);
const NODE_MAJOR_VERSION = 18;
const nativeNodeModulesPlugin = {
name: 'native-node-modules',
@@ -35,7 +27,7 @@ export default () => {
entryPoints: ['layers/main/src/index.ts'],
outdir: 'dist/layers/main',
bundle: true,
target: `node${node}`,
target: `node${NODE_MAJOR_VERSION}`,
platform: 'node',
external: ['electron'],
plugins: [nativeNodeModulesPlugin],
@@ -45,7 +37,7 @@ export default () => {
entryPoints: ['layers/preload/src/index.ts'],
outdir: 'dist/layers/preload',
bundle: true,
target: `node${node}`,
target: `node${NODE_MAJOR_VERSION}`,
platform: 'node',
external: ['electron'],
define: define,

View File

@@ -1,17 +0,0 @@
/**
* This script should be run in electron context
* @example
* ELECTRON_RUN_AS_NODE=1 electron scripts/update-electron-vendors.mjs
*/
import { writeFileSync } from 'fs';
const electronRelease = process.versions;
const node = electronRelease.node.split('.')[0];
const chrome = electronRelease.v8.split('.').splice(0, 2).join('');
writeFileSync(
'./electron-vendors.autogen.json',
JSON.stringify({ chrome, node })
);