mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
refactor: use esbuild instead of vite (#2672)
(cherry picked from commit acda594cba)
This commit is contained in:
9
apps/electron/scripts/plugins/build-plugins.mjs
Executable file
9
apps/electron/scripts/plugins/build-plugins.mjs
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
import { build } from 'esbuild';
|
||||
|
||||
import { definePluginServerConfig } from './utils.mjs';
|
||||
|
||||
await build({
|
||||
...definePluginServerConfig('bookmark-block'),
|
||||
external: ['cheerio', 'electron'],
|
||||
});
|
||||
11
apps/electron/scripts/plugins/dev-plugins.mjs
Executable file
11
apps/electron/scripts/plugins/dev-plugins.mjs
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env node
|
||||
import { context } from 'esbuild';
|
||||
|
||||
import { definePluginServerConfig } from './utils.mjs';
|
||||
|
||||
const plugin = await context({
|
||||
...definePluginServerConfig('bookmark-block'),
|
||||
external: ['cheerio', 'electron'],
|
||||
});
|
||||
|
||||
await plugin.watch();
|
||||
29
apps/electron/scripts/plugins/utils.mjs
Normal file
29
apps/electron/scripts/plugins/utils.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user