From 4941be6197272d62deef705f413ca01b53f2e409 Mon Sep 17 00:00:00 2001 From: Kamenskih Dmitriy Date: Fri, 16 Aug 2024 23:05:30 +0400 Subject: [PATCH] fix(node): build-esbuild-options.ts browser user define envs by config (#27480) ## Current Behavior When you use esbuild in 'browser' mode you have to provide all 'define' attributes as environment variables and only with "NX_PUBLIC_" prefix ## Expected Behavior Esbuild configuration has to work as it is described in docs. And prefix feature has to work as an additional functionality ## Related Issue(s) This issue will be fixed: https://github.com/nrwl/nx/issues/19106 Co-authored-by: Dmitrii Kamenskikh --- .../src/executors/esbuild/lib/build-esbuild-options.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/esbuild/src/executors/esbuild/lib/build-esbuild-options.ts b/packages/esbuild/src/executors/esbuild/lib/build-esbuild-options.ts index 73d7ebb05b838..ae4337ed165f5 100644 --- a/packages/esbuild/src/executors/esbuild/lib/build-esbuild-options.ts +++ b/packages/esbuild/src/executors/esbuild/lib/build-esbuild-options.ts @@ -49,7 +49,10 @@ export function buildEsbuildOptions( }; if (options.platform === 'browser') { - esbuildOptions.define = getClientEnvironment(); + esbuildOptions.define = { + ...getClientEnvironment(), + ...options.userDefinedBuildOptions?.define, + }; } if (!esbuildOptions.outfile && !esbuildOptions.outdir) {