2023-10-18 09:13:47 +03:00
|
|
|
import { resolve } from 'node:path';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
|
|
|
|
import type { BuildOptions } from 'esbuild';
|
|
|
|
|
|
|
|
export const electronDir = fileURLToPath(new URL('..', import.meta.url));
|
|
|
|
|
2023-10-18 18:30:08 +03:00
|
|
|
export const rootDir = resolve(electronDir, '..', '..', '..');
|
2023-10-18 09:13:47 +03:00
|
|
|
|
|
|
|
export const NODE_MAJOR_VERSION = 18;
|
|
|
|
|
|
|
|
export const mode = (process.env.NODE_ENV =
|
|
|
|
process.env.NODE_ENV || 'development');
|
|
|
|
|
|
|
|
export const config = (): BuildOptions => {
|
2023-10-19 06:14:30 +03:00
|
|
|
const define: Record<string, string> = {};
|
2023-10-18 09:13:47 +03:00
|
|
|
|
2023-10-19 06:14:30 +03:00
|
|
|
define['REPLACE_ME_BUILD_ENV'] = `"${process.env.BUILD_TYPE ?? 'stable'}"`;
|
2023-10-18 09:13:47 +03:00
|
|
|
|
|
|
|
return {
|
|
|
|
entryPoints: [
|
|
|
|
resolve(electronDir, './src/main/index.ts'),
|
|
|
|
resolve(electronDir, './src/preload/index.ts'),
|
|
|
|
resolve(electronDir, './src/helper/index.ts'),
|
|
|
|
],
|
|
|
|
entryNames: '[dir]',
|
|
|
|
outdir: resolve(electronDir, './dist'),
|
|
|
|
bundle: true,
|
|
|
|
target: `node${NODE_MAJOR_VERSION}`,
|
|
|
|
platform: 'node',
|
|
|
|
external: [
|
|
|
|
'electron',
|
|
|
|
'electron-updater',
|
|
|
|
'@toeverything/plugin-infra',
|
|
|
|
'yjs',
|
|
|
|
'semver',
|
|
|
|
'tinykeys',
|
|
|
|
],
|
|
|
|
format: 'cjs',
|
|
|
|
loader: {
|
|
|
|
'.node': 'copy',
|
|
|
|
},
|
2023-10-19 06:14:30 +03:00
|
|
|
define,
|
2023-10-18 09:13:47 +03:00
|
|
|
assetNames: '[name]',
|
|
|
|
treeShaking: true,
|
|
|
|
sourcemap: 'linked',
|
|
|
|
};
|
|
|
|
};
|