mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
refactor: avoid runtime config object (#8202)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import type { RuntimeConfig } from '@affine/env/global';
|
||||
import type { BUILD_CONFIG_TYPE } from '@affine/env/global';
|
||||
import { PerfseePlugin } from '@perfsee/webpack';
|
||||
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
|
||||
import { sentryWebpackPlugin } from '@sentry/webpack-plugin';
|
||||
@@ -89,8 +89,8 @@ export const getPublicPath = (buildFlags: BuildFlags) => {
|
||||
export const createConfiguration: (
|
||||
cwd: string,
|
||||
buildFlags: BuildFlags,
|
||||
runtimeConfig: RuntimeConfig
|
||||
) => webpack.Configuration = (cwd, buildFlags, runtimeConfig) => {
|
||||
buildConfig: BUILD_CONFIG_TYPE
|
||||
) => webpack.Configuration = (cwd, buildFlags, buildConfig) => {
|
||||
const blocksuiteBaseDir = buildFlags.localBlockSuite;
|
||||
const config = {
|
||||
name: 'affine',
|
||||
@@ -350,8 +350,12 @@ export const createConfiguration: (
|
||||
process.env.MIXPANEL_TOKEN
|
||||
),
|
||||
'process.env.DEBUG_JOTAI': JSON.stringify(process.env.DEBUG_JOTAI),
|
||||
'process.env.RUNTIME_CONFIG': JSON.stringify(
|
||||
JSON.stringify(runtimeConfig)
|
||||
...Object.entries(buildConfig).reduce(
|
||||
(def, [k, v]) => {
|
||||
def[`BUILD_CONFIG.${k}`] = JSON.stringify(v);
|
||||
return def;
|
||||
},
|
||||
{} as Record<string, string>
|
||||
),
|
||||
}),
|
||||
buildFlags.distribution === 'admin'
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { RuntimeConfig } from '@affine/env/global';
|
||||
import type { BUILD_CONFIG_TYPE } from '@affine/env/global';
|
||||
|
||||
import packageJson from '../../package.json' assert { type: 'json' };
|
||||
import type { BuildFlags } from '../config';
|
||||
|
||||
export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
|
||||
const buildPreset: Record<BuildFlags['channel'], RuntimeConfig> = {
|
||||
export function getRuntimeConfig(buildFlags: BuildFlags): BUILD_CONFIG_TYPE {
|
||||
const buildPreset: Record<BuildFlags['channel'], BUILD_CONFIG_TYPE> = {
|
||||
get stable() {
|
||||
return {
|
||||
distribution: buildFlags.distribution,
|
||||
@@ -21,13 +21,10 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
|
||||
enableExperimentalFeature: true,
|
||||
allowLocalWorkspace:
|
||||
buildFlags.distribution === 'desktop' ? true : false,
|
||||
enableOrganize: true,
|
||||
enableInfoModal: true,
|
||||
enableThemeEditor: false,
|
||||
|
||||
// CAUTION(@forehalo): product not ready, do not enable it
|
||||
enableNewSettingUnstableApi: false,
|
||||
enableEnhanceShareMode: false,
|
||||
enableThemeEditor: false,
|
||||
};
|
||||
},
|
||||
get beta() {
|
||||
@@ -53,8 +50,6 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
|
||||
appBuildType: 'canary' as const,
|
||||
serverUrlPrefix: 'https://affine.fail',
|
||||
changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
|
||||
enableInfoModal: true,
|
||||
enableOrganize: true,
|
||||
enableThemeEditor: true,
|
||||
};
|
||||
},
|
||||
@@ -76,9 +71,6 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
|
||||
enableNewSettingUnstableApi: process.env.ENABLE_NEW_SETTING_UNSTABLE_API
|
||||
? process.env.ENABLE_NEW_SETTING_UNSTABLE_API === 'true'
|
||||
: currentBuildPreset.enableNewSettingUnstableApi,
|
||||
enableEnhanceShareMode: process.env.ENABLE_ENHANCE_SHARE_MODE
|
||||
? process.env.ENABLE_ENHANCE_SHARE_MODE === 'true'
|
||||
: currentBuildPreset.enableEnhanceShareMode,
|
||||
allowLocalWorkspace: process.env.ALLOW_LOCAL_WORKSPACE
|
||||
? process.env.ALLOW_LOCAL_WORKSPACE === 'true'
|
||||
: buildFlags.mode === 'development'
|
||||
|
||||
Reference in New Issue
Block a user