File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,30 @@ import { fileURLToPath } from 'node:url';
44import path from 'node:path' ;
55import dotenv from 'dotenv' ;
66import proxy from './server/app.js' ;
7+ import { copyFileSync } from 'node:fs' ;
78
89dotenv . config ( ) ;
910
11+ const isDev = process . argv . includes ( '--dev' ) ;
12+
1013const __filename = fileURLToPath ( import . meta. url ) ;
1114const __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
1332const fastify = Fastify ( {
1433 logger : true ,
@@ -20,7 +39,7 @@ fastify.register(proxy, {
2039
2140await fastify . register ( FastifyVite , {
2241 root : __dirname ,
23- dev : process . argv . includes ( '--dev' ) ,
42+ dev : isDev ,
2443 spa : true ,
2544} ) ;
2645
You can’t perform that action at this time.
0 commit comments