Skip to content

Commit 4d0a819

Browse files
committed
fix: added step for copying frontend-config from env var.
1 parent 9a83997 commit 4d0a819

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

server.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,30 @@ import { fileURLToPath } from 'node:url';
44
import path from 'node:path';
55
import dotenv from 'dotenv';
66
import proxy from './server/app.js';
7+
import { copyFileSync } from 'node:fs';
78

89
dotenv.config();
910

11+
const isDev = process.argv.includes('--dev');
12+
1013
const __filename = fileURLToPath(import.meta.url);
1114
const __dirname = path.dirname(__filename);
15+
const frontendConfigLocation = isDev
16+
? 'public/frontend-config.json'
17+
: 'dist/client/frontend-config.json';
18+
19+
if (
20+
process.env.FRONTEND_CONFIG_PATH !== undefined &&
21+
process.env.FRONTEND_CONFIG_PATH.length > 0
22+
) {
23+
console.log(
24+
'FRONTEND_CONFIG_PATH is specified. Will copy the frontend-config from there.',
25+
);
26+
console.log(
27+
` Copying ${process.env.FRONTEND_CONFIG_PATH} to ${frontendConfigLocation}`,
28+
);
29+
copyFileSync(process.env.FRONTEND_CONFIG_PATH, frontendConfigLocation);
30+
}
1231

1332
const fastify = Fastify({
1433
logger: true,
@@ -20,7 +39,7 @@ fastify.register(proxy, {
2039

2140
await fastify.register(FastifyVite, {
2241
root: __dirname,
23-
dev: process.argv.includes('--dev'),
42+
dev: isDev,
2443
spa: true,
2544
});
2645

0 commit comments

Comments
 (0)