Skip to content

Commit 2cf12e1

Browse files
committed
fix: ssr apps process env variables
1 parent 357cdf2 commit 2cf12e1

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

angular/app-types/angular-app-type/angular.application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class AngularApp implements Application {
187187
logger: logger,
188188
tempFolder: tempFolder,
189189
envVars: {
190-
'process.env': envVars
190+
process: { env: envVars }
191191
}
192192
});
193193
} else {

angular/app-types/angular-app-type/plugins/define.plugin.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Plugin, PluginBuild } from 'esbuild';
2+
import { merge } from 'lodash';
23

34
export const stringifyDefine = (define: any) => {
45
return Object.entries(define).reduce((acc: any, [key, value]) => {
@@ -11,18 +12,9 @@ export const stringifyDefine = (define: any) => {
1112
* Pass environment variables to esbuild.
1213
* @returns An esbuild plugin.
1314
*/
14-
export default function(defineValues = {}) {
15+
export default function(defineValues: any = {}) {
1516
// set variables on global so that they also work during ssr
16-
const keys = Object.keys(defineValues);
17-
keys.forEach((key: any) => {
18-
// @ts-ignore
19-
if (global[key]) {
20-
throw new Error(`Define plugin: key ${ key } already exists on global`);
21-
} else {
22-
// @ts-ignore
23-
global[key] = defineValues[key];
24-
}
25-
});
17+
merge(global, defineValues);
2618

2719
const plugin: Plugin = {
2820
name: 'env',

0 commit comments

Comments
 (0)