@@ -2,38 +2,44 @@ import { defineConfig } from "@farmfe/core";
2
2
import farmPostcssPlugin from "@farmfe/js-plugin-postcss" ;
3
3
import path from "path" ;
4
4
5
- const env = {
6
- SD_BACKEND_URL : process . env . SD_BACKEND_URL ,
7
- SD_CLIENT_ID : process . env . SD_CLIENT_ID ,
8
- SD_AUTHORITY_URL : process . env . SD_AUTHORITY_URL ,
9
- SD_REDIRECT_URL : process . env . SD_REDIRECT_URL ,
10
- SD_LOGOUT_REDIRECT_URL : process . env . SD_LOGOUT_REDIRECT_URL ,
11
- SD_AUTH_SECRET : process . env . SD_AUTH_SECRET ,
12
- } ;
5
+ export default defineConfig ( ( cfg ) => {
6
+ let env : object | undefined ;
13
7
14
- for ( const [ key , value ] of Object . entries ( env ) ) {
15
- if ( ! value ) {
16
- throw new Error ( `Environment variable ${ key } is missing or empty.` ) ;
17
- }
18
- }
8
+ if ( cfg . mode !== "development" ) {
9
+ env = {
10
+ SD_BACKEND_URL : process . env . SD_BACKEND_URL ,
11
+ SD_CLIENT_ID : process . env . SD_CLIENT_ID ,
12
+ SD_AUTHORITY_URL : process . env . SD_AUTHORITY_URL ,
13
+ SD_REDIRECT_URL : process . env . SD_REDIRECT_URL ,
14
+ SD_LOGOUT_REDIRECT_URL : process . env . SD_LOGOUT_REDIRECT_URL ,
15
+ SD_AUTH_SECRET : process . env . SD_AUTH_SECRET ,
16
+ } ;
19
17
20
- export default defineConfig ( {
21
- plugins : [ "@farmfe/plugin-react" , farmPostcssPlugin ( ) ] ,
22
- compilation : {
23
- resolve : {
24
- alias : {
25
- "~/" : path . join ( process . cwd ( ) , "src" ) ,
18
+ for ( const [ key , value ] of Object . entries ( env ) ) {
19
+ if ( ! value ) {
20
+ throw new Error ( `Environment variable ${ key } is missing or empty.` ) ;
26
21
}
22
+ }
23
+ }
24
+
25
+ return {
26
+ plugins : [ "@farmfe/plugin-react" , farmPostcssPlugin ( ) ] ,
27
+ compilation : {
28
+ resolve : {
29
+ alias : {
30
+ "~/" : path . join ( process . cwd ( ) , "src" ) ,
31
+ }
32
+ } ,
33
+ define : env ,
27
34
} ,
28
- define : env ,
29
- } ,
30
- envPrefix : "SD_" ,
31
- server : {
32
- proxy : {
33
- "/api" : {
34
- target : "https://status.cloudmon.eco.tsi-dev.otc-service.com" ,
35
- changeOrigin : true
35
+ envPrefix : "SD_" ,
36
+ server : {
37
+ proxy : {
38
+ "/api" : {
39
+ target : "https://status.cloudmon.eco.tsi-dev.otc-service.com" ,
40
+ changeOrigin : true
41
+ }
36
42
}
37
43
}
38
- }
44
+ } ;
39
45
} ) ;
0 commit comments