2023-03-16 17:58:21 +03:00
|
|
|
import fs from 'node:fs';
|
|
|
|
import path from 'node:path';
|
2023-03-18 16:43:39 +03:00
|
|
|
import * as url from 'node:url';
|
|
|
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
|
|
// const __dirname = new URL('.', import.meta.url).pathname;
|
2023-03-16 17:58:21 +03:00
|
|
|
const { node } = JSON.parse(
|
|
|
|
fs.readFileSync(
|
|
|
|
path.join(__dirname, '../electron-vendors.autogen.json'),
|
|
|
|
'utf-8'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2023-03-28 02:03:11 +03:00
|
|
|
const nativeNodeModulesPlugin = {
|
|
|
|
name: 'native-node-modules',
|
|
|
|
setup(build) {
|
|
|
|
// Mark native Node.js modules as external
|
|
|
|
build.onResolve({ filter: /\.node$/, namespace: 'file' }, args => {
|
|
|
|
return { path: args.path, external: true };
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-03-16 17:58:21 +03:00
|
|
|
/** @type {import('esbuild').BuildOptions} */
|
|
|
|
export const mainConfig = {
|
|
|
|
entryPoints: ['layers/main/src/index.ts'],
|
|
|
|
outdir: 'dist/layers/main',
|
|
|
|
bundle: true,
|
|
|
|
target: `node${node}`,
|
|
|
|
platform: 'node',
|
|
|
|
external: ['electron'],
|
2023-03-28 02:03:11 +03:00
|
|
|
plugins: [nativeNodeModulesPlugin],
|
2023-03-16 17:58:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export const preloadConfig = {
|
|
|
|
entryPoints: ['layers/preload/src/index.ts'],
|
|
|
|
outdir: 'dist/layers/preload',
|
|
|
|
bundle: true,
|
|
|
|
target: `node${node}`,
|
|
|
|
platform: 'node',
|
|
|
|
external: ['electron'],
|
|
|
|
};
|