chore(core): split sentry and setup into web/electron (#6357)

This commit is contained in:
Brooooooklyn
2024-03-28 10:24:25 +00:00
parent 88d04e23e9
commit c2847e2082
17 changed files with 463 additions and 198 deletions

View File

@@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { getRuntimeConfig } from '@affine/cli/src/webpack/runtime-config';
import { sentryEsbuildPlugin } from '@sentry/esbuild-plugin';
import type { BuildOptions } from 'esbuild';
export const electronDir = fileURLToPath(new URL('..', import.meta.url));
@@ -28,6 +29,26 @@ export const config = (): BuildOptions => {
})
);
if (process.env.GITHUB_SHA) {
define['process.env.GITHUB_SHA'] = `"${process.env.GITHUB_SHA}"`;
}
const plugins = [];
if (
process.env.SENTRY_AUTH_TOKEN &&
process.env.SENTRY_ORG &&
process.env.SENTRY_PROJECT
) {
plugins.push(
sentryEsbuildPlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
})
);
}
return {
entryPoints: [
resolve(electronDir, './src/main/index.ts'),
@@ -48,5 +69,6 @@ export const config = (): BuildOptions => {
assetNames: '[name]',
treeShaking: true,
sourcemap: 'linked',
plugins,
};
};