Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

perf: remove `data-testid` in production (#2228)

阿良仔92859bf8b955
diff --git a/.github/workflows/release-desktop-app.yml b/.github/workflows/release-desktop-app.yml
index c8cd109dd7..da77b8ebda 100644
--- a/.github/workflows/release-desktop-app.yml
+++ b/.github/workflows/release-desktop-app.yml
@@ -63,6 +63,7 @@ jobs:
NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
API_SERVER_PROFILE: prod
+ ENABLE_TEST_PROPERTIES: false
- name: Upload Artifact (web-static)
uses: actions/upload-artifact@v3
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index bed8a77a25..2d9a43220a 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -80,6 +80,11 @@ const nextConfig = {
removeConsole: {
exclude: ['error', 'log', 'warn', 'info'],
},
+ reactRemoveProperties: !buildFlags.enableTestProperties
+ ? {
+ properties: ['^data-testid$'],
+ }
+ : false,
emotion: {
sourceMap: true,
},
diff --git a/apps/web/preset.config.mjs b/apps/web/preset.config.mjs
index ac5d2a0671..d8f57d2250 100644
--- a/apps/web/preset.config.mjs
+++ b/apps/web/preset.config.mjs
@@ -18,6 +18,9 @@ export const blockSuiteFeatureFlags = {
* @type {import('@affine/env').BuildFlags}
*/
export const buildFlags = {
+ enableTestProperties: process.env.ENABLE_TEST_PROPERTIES
+ ? process.env.ENABLE_TEST_PROPERTIES === 'true'
+ : true,
enableLegacyCloud: process.env.ENABLE_LEGACY_PROVIDER
? process.env.ENABLE_LEGACY_PROVIDER === 'true'
: true,
diff --git a/packages/env/src/config.ts b/packages/env/src/config.ts
index 8d97eb795b..79f093bd7b 100644
--- a/packages/env/src/config.ts
+++ b/packages/env/src/config.ts
@@ -6,6 +6,7 @@ import { z } from 'zod';
import { getUaHelper } from './ua-helper';
export const buildFlagsSchema = z.object({
+ enableTestProperties: z.boolean(),
enableBroadCastChannelProvider: z.boolean(),
enableDebugPage: z.boolean(),
enableLegacyCloud: z.boolean(),