feat(electron): define runtimeConfig in esbuild (#6287)
This commit is contained in:
6
packages/common/env/tsconfig.json
vendored
6
packages/common/env/tsconfig.json
vendored
@@ -6,9 +6,5 @@
|
|||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
"references": [
|
"references": []
|
||||||
{
|
|
||||||
"path": "../../../tests/fixtures"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ async function buildLayers() {
|
|||||||
const common = config();
|
const common = config();
|
||||||
|
|
||||||
const define: Record<string, string> = {
|
const define: Record<string, string> = {
|
||||||
|
...common.define,
|
||||||
'process.env.NODE_ENV': `"${mode}"`,
|
'process.env.NODE_ENV': `"${mode}"`,
|
||||||
'process.env.BUILD_TYPE': `"${process.env.BUILD_TYPE || 'stable'}"`,
|
'process.env.BUILD_TYPE': `"${process.env.BUILD_TYPE || 'stable'}"`,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
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';
|
import type { BuildOptions } from 'esbuild';
|
||||||
|
|
||||||
export const electronDir = fileURLToPath(new URL('..', import.meta.url));
|
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['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 {
|
return {
|
||||||
entryPoints: [
|
entryPoints: [
|
||||||
resolve(electronDir, './src/main/index.ts'),
|
resolve(electronDir, './src/main/index.ts'),
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"target": "ESNext",
|
"target": "ES2022",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"types": ["node"],
|
"types": ["node", "affine__env"],
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"outDir": "./lib/scripts",
|
"outDir": "./lib/scripts",
|
||||||
"types": ["node"],
|
"types": ["node", "affine__env"],
|
||||||
"allowJs": true
|
"allowJs": true
|
||||||
},
|
},
|
||||||
"include": ["./scripts"],
|
"include": ["./scripts"],
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"outDir": "./lib/tests",
|
"outDir": "./lib/tests",
|
||||||
"types": ["node"],
|
"types": ["node", "affine__env"],
|
||||||
"allowJs": true
|
"allowJs": true
|
||||||
},
|
},
|
||||||
"references": [
|
"references": [
|
||||||
|
|||||||
Reference in New Issue
Block a user