Skip to content

Commit

Permalink
fix: ssr apps process env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe committed Feb 2, 2024
1 parent 357cdf2 commit 2cf12e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion angular/app-types/angular-app-type/angular.application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class AngularApp implements Application {
logger: logger,
tempFolder: tempFolder,
envVars: {
'process.env': envVars
process: { env: envVars }
}
});
} else {
Expand Down
14 changes: 3 additions & 11 deletions angular/app-types/angular-app-type/plugins/define.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Plugin, PluginBuild } from 'esbuild';
import { merge } from 'lodash';

export const stringifyDefine = (define: any) => {
return Object.entries(define).reduce((acc: any, [key, value]) => {
Expand All @@ -11,18 +12,9 @@ export const stringifyDefine = (define: any) => {
* Pass environment variables to esbuild.
* @returns An esbuild plugin.
*/
export default function(defineValues = {}) {
export default function(defineValues: any = {}) {
// set variables on global so that they also work during ssr
const keys = Object.keys(defineValues);
keys.forEach((key: any) => {
// @ts-ignore
if (global[key]) {
throw new Error(`Define plugin: key ${ key } already exists on global`);
} else {
// @ts-ignore
global[key] = defineValues[key];
}
});
merge(global, defineValues);

const plugin: Plugin = {
name: 'env',
Expand Down

0 comments on commit 2cf12e1

Please sign in to comment.