+14
packages/extension/build.js
+14
packages/extension/build.js
···
6
6
const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
7
8
8
const watch = process.argv.includes('--watch');
9
+
const isProd = process.argv.includes('--prod') || process.env.NODE_ENV === 'production';
10
+
const mode = isProd ? 'production' : 'development';
11
+
12
+
// Environment-specific configuration
13
+
const ATLAST_API_URL = mode === 'production'
14
+
? 'https://atlast.byarielm.fyi'
15
+
: 'http://127.0.0.1:8888';
16
+
17
+
console.log(`🌍 Building for ${mode} mode`);
18
+
console.log(`🔗 API URL: ${ATLAST_API_URL}`);
9
19
10
20
// Clean dist directory
11
21
const distDir = path.join(__dirname, 'dist', 'chrome');
···
21
31
sourcemap: watch ? 'inline' : false,
22
32
target: 'es2020',
23
33
format: 'esm',
34
+
define: {
35
+
'__ATLAST_API_URL__': JSON.stringify(ATLAST_API_URL),
36
+
'__BUILD_MODE__': JSON.stringify(mode),
37
+
},
24
38
};
25
39
26
40
// Build scripts
+3
-1
packages/extension/package.json
+3
-1
packages/extension/package.json
···
6
6
"type": "module",
7
7
"scripts": {
8
8
"build": "node build.js",
9
+
"build:prod": "node build.js --prod",
9
10
"dev": "node build.js --watch",
10
-
"package:chrome": "cd dist/chrome && zip -r ../chrome.zip ."
11
+
"package:chrome": "cd dist/chrome && zip -r ../chrome.zip .",
12
+
"package:prod": "npm run build:prod && npm run package:chrome"
11
13
},
12
14
"dependencies": {
13
15
"@atlast/shared": "workspace:*"
+9
-4
packages/extension/src/lib/api-client.ts
+9
-4
packages/extension/src/lib/api-client.ts
···
2
2
* ATlast API client for extension
3
3
*/
4
4
5
-
// API URL configuration
6
-
const ATLAST_API_URL = import.meta.env?.MODE === 'production'
7
-
? 'https://atlast.byarielm.fyi'
8
-
: 'http://127.0.0.1:8888';
5
+
// These are replaced at build time by esbuild
6
+
declare const __ATLAST_API_URL__: string;
7
+
declare const __BUILD_MODE__: string;
8
+
9
+
// API URL configuration - injected at build time
10
+
const ATLAST_API_URL = __ATLAST_API_URL__;
11
+
12
+
console.log(`[API Client] Running in ${__BUILD_MODE__} mode`);
13
+
console.log(`[API Client] API URL: ${ATLAST_API_URL}`);
9
14
10
15
export interface ExtensionImportRequest {
11
16
platform: string;