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.

feat: improve scripts

DarkSky462e86b9a075
diff --git a/package.json b/package.json
index 1abcf66a9b..7c9ac38d11 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,8 @@
"license": "MPL-2.0",
"scripts": {
"dev": "pnpm --filter=!@affine/app build && pnpm --filter @affine/app dev",
- "dev:ac": "pnpm --filter=!@affine/app build && pnpm --filter @affine/app dev:ac",
+ "dev:ac": "pnpm --filter=!@affine/app build && NODE_API_SERVER=ac pnpm --filter @affine/app dev",
+ "dev:local": "pnpm --filter=!@affine/app build && NODE_API_SERVER=local pnpm --filter @affine/app dev",
"build": " pnpm --filter=!@affine/app build && pnpm --filter!=@affine/datacenter -r build",
"export": "pnpm --filter @affine/app export",
"start": "pnpm --filter @affine/app start",
diff --git a/packages/app/next.config.js b/packages/app/next.config.js
index 10da796485..df91a70108 100644
--- a/packages/app/next.config.js
+++ b/packages/app/next.config.js
@@ -9,6 +9,27 @@ const EDITOR_VERSION = enableDebugLocal
? 'local-version'
: dependencies['@blocksuite/editor'];
+const profileTarget = {
+ ac: '100.85.73.88:12001',
+ dev: '100.85.73.88:12001',
+ local: '127.0.0.1:3000',
+};
+
+const getRedirectConfig = profile => {
+ const target = profileTarget[profile || 'dev'] || profileTarget['dev'];
+
+ return [
+ [
+ { source: '/api/:path*', destination: `http://${target}/api/:path*` },
+ {
+ source: '/collaboration/:path*',
+ destination: `http://${target}/collaboration/:path*`,
+ },
+ ],
+ target,
+ ];
+};
+
/** @type {import('next').NextConfig} */
const nextConfig = {
productionBrowserSourceMaps: true,
@@ -36,38 +57,12 @@ const nextConfig = {
images: {
unoptimized: true,
},
- // XXX not test yet
rewrites: async () => {
- if (process.env.NODE_API_SERVER === 'ac') {
- let destinationAC = 'http://100.85.73.88:12001/api/:path*';
- printer.info('API request proxy to [AC Server] ' + destinationAC);
- return [
- {
- source: '/api/:path*',
- destination: destinationAC,
- },
- {
- source: '/collaboration/:path*',
- destination: 'http://localhost:3000/collaboration/:path*',
- },
- ];
- } else {
- let destinationStandard = 'http://100.77.180.48:11001/api/:path*';
- printer.info(
- 'API request proxy to [Standard Server] ' + destinationStandard
- );
-
- return [
- {
- source: '/api/:path*',
- destination: destinationStandard,
- },
- {
- source: '/collaboration/:path*',
- destination: 'http://localhost:3000/collaboration/:path*',
- },
- ];
- }
+ const [profile, desc] = getRedirectConfig(process.env.NODE_API_SERVER);
+ printer.info(
+ `API request proxy to [${process.env.NODE_API_SERVER} Server]: ` + desc
+ );
+ return profile;
},
basePath: process.env.BASE_PATH,
};
diff --git a/packages/app/package.json b/packages/app/package.json
index 9dac686ae9..3ba74e2712 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -3,7 +3,6 @@
"version": "0.3.1",
"scripts": {
"dev": "next dev -p 8080",
- "dev:ac": "NODE_API_SERVER=ac next dev -p 8080",
"build": "next build",
"export": "next export",
"start": "next start",