File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 11import path from 'path' ;
22
3+ import { parseNumber } from '@douglasneuroinformatics/libjs' ;
34import importMetaEnv from '@import-meta-env/unplugin' ;
45import { getReleaseInfo } from '@opendatacapture/release-info' ;
56import runtime from '@opendatacapture/vite-plugin-runtime' ;
@@ -9,6 +10,15 @@ import react from '@vitejs/plugin-react-swc';
910import { defineConfig } from 'vite' ;
1011import viteCompression from 'vite-plugin-compression' ;
1112
13+ const apiPort = parseNumber ( process . env . API_DEV_SERVER_PORT ) ;
14+ const webPort = parseNumber ( process . env . WEB_DEV_SERVER_PORT ) ;
15+
16+ if ( Number . isNaN ( apiPort ) ) {
17+ throw new Error ( `Expected API_DEV_SERVER_PORT to be number, got ${ process . env . API_DEV_SERVER_PORT } ` ) ;
18+ } else if ( Number . isNaN ( webPort ) ) {
19+ throw new Error ( `Expected WEB_DEV_SERVER_PORT to be number, got ${ process . env . WEB_DEV_SERVER_PORT } ` ) ;
20+ }
21+
1222export default defineConfig ( {
1323 build : {
1424 chunkSizeWarningLimit : 1000 ,
@@ -45,13 +55,13 @@ export default defineConfig({
4555 }
4656 } ,
4757 server : {
48- port : parseInt ( process . env . WEB_DEV_SERVER_PORT ?? '3000' ) ,
58+ port : webPort ,
4959 proxy : {
5060 '/api/' : {
5161 rewrite : ( path ) => path . replace ( / ^ \/ a p i / , '' ) ,
5262 target : {
5363 host : 'localhost' ,
54- port : parseInt ( process . env . API_DEV_SERVER_PORT ?? '5500' )
64+ port : apiPort
5565 }
5666 }
5767 }
You can’t perform that action at this time.
0 commit comments