AFFiNE/scripts/esbuild/utils.mjs
2023-06-02 13:22:09 +00:00

30 lines
774 B
JavaScript

import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
export const rootDir = fileURLToPath(new URL('../..', import.meta.url));
export const electronOutputDir = resolve(
rootDir,
'apps',
'electron',
'dist',
'plugins'
);
export const pluginDir = resolve(rootDir, 'plugins');
/**
*
* @param pluginDirName {string}
* @return {import('esbuild').BuildOptions}
*/
export function definePluginServerConfig(pluginDirName) {
const pluginRootDir = resolve(pluginDir, pluginDirName);
const serverEntryFile = resolve(pluginRootDir, 'src/server.ts');
const serverOutputDir = resolve(electronOutputDir, pluginDirName);
return {
entryPoints: [serverEntryFile],
platform: 'node',
outdir: serverOutputDir,
bundle: true,
};
}