mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat(electron): define runtimeConfig in esbuild (#6287)
This commit is contained in:
@@ -6,6 +6,7 @@ async function buildLayers() {
|
||||
const common = config();
|
||||
|
||||
const define: Record<string, string> = {
|
||||
...common.define,
|
||||
'process.env.NODE_ENV': `"${mode}"`,
|
||||
'process.env.BUILD_TYPE': `"${process.env.BUILD_TYPE || 'stable'}"`,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||
import { getRuntimeConfig } from '@affine/cli/src/webpack/runtime-config';
|
||||
import type { BuildOptions } from 'esbuild';
|
||||
|
||||
export const electronDir = fileURLToPath(new URL('..', import.meta.url));
|
||||
@@ -17,6 +19,15 @@ export const config = (): BuildOptions => {
|
||||
|
||||
define['REPLACE_ME_BUILD_ENV'] = `"${process.env.BUILD_TYPE ?? 'stable'}"`;
|
||||
|
||||
define['runtimeConfig'] = JSON.stringify(
|
||||
getRuntimeConfig({
|
||||
channel: (process.env.BUILD_TYPE as any) ?? 'canary',
|
||||
distribution: 'desktop',
|
||||
mode:
|
||||
process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
entryPoints: [
|
||||
resolve(electronDir, './src/main/index.ts'),
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "ESNext",
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"types": ["node"],
|
||||
"types": ["node", "affine__env"],
|
||||
"outDir": "lib",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noEmit": false,
|
||||
"outDir": "./lib/scripts",
|
||||
"types": ["node"],
|
||||
"types": ["node", "affine__env"],
|
||||
"allowJs": true
|
||||
},
|
||||
"include": ["./scripts"],
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noEmit": false,
|
||||
"outDir": "./lib/tests",
|
||||
"types": ["node"],
|
||||
"types": ["node", "affine__env"],
|
||||
"allowJs": true
|
||||
},
|
||||
"references": [
|
||||
|
||||
Reference in New Issue
Block a user