diff --git a/packages/angular/src/generators/utils/add-mf-env-to-inputs.ts b/packages/angular/src/generators/utils/add-mf-env-to-inputs.ts index 24baff9ffe9ed..c10319fa4eb1a 100644 --- a/packages/angular/src/generators/utils/add-mf-env-to-inputs.ts +++ b/packages/angular/src/generators/utils/add-mf-env-to-inputs.ts @@ -5,12 +5,15 @@ export function addMfEnvToTargetDefaultInputs(tree: Tree) { const webpackExecutor = '@nx/angular:webpack-browser'; const mfEnvVar = 'NX_MF_DEV_REMOTES'; + const inputs = [ + ...(nxJson.namedInputs && 'production' in nxJson.namedInputs + ? ['production', '^production'] + : ['default', '^default']), + ]; + nxJson.targetDefaults ??= {}; nxJson.targetDefaults[webpackExecutor] ??= {}; - nxJson.targetDefaults[webpackExecutor].inputs ??= [ - 'production', - '^production', - ]; + nxJson.targetDefaults[webpackExecutor].inputs ??= inputs; nxJson.targetDefaults[webpackExecutor].dependsOn ??= ['^build']; let mfEnvVarExists = false; diff --git a/packages/angular/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.spec.ts b/packages/angular/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.spec.ts index 2ace3376d72da..ebcfbf99ac956 100644 --- a/packages/angular/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.spec.ts +++ b/packages/angular/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.spec.ts @@ -30,8 +30,8 @@ describe('addMfEnvVarToTargetDefaults', () => { "^build", ], "inputs": [ - "production", - "^production", + "default", + "^default", { "env": "NX_MF_DEV_REMOTES", }, diff --git a/packages/angular/src/migrations/update-19-6-1/ensure-depends-on-for-mf.spec.ts b/packages/angular/src/migrations/update-19-6-1/ensure-depends-on-for-mf.spec.ts index ebef7640a821f..15678a801270b 100644 --- a/packages/angular/src/migrations/update-19-6-1/ensure-depends-on-for-mf.spec.ts +++ b/packages/angular/src/migrations/update-19-6-1/ensure-depends-on-for-mf.spec.ts @@ -60,8 +60,8 @@ describe('ensure-depends-on-for-mf', () => { "^build", ], "inputs": [ - "production", - "^production", + "default", + "^default", { "env": "NX_MF_DEV_REMOTES", }, diff --git a/packages/angular/src/migrations/update-19-6-1/ensure-depends-on-for-mf.ts b/packages/angular/src/migrations/update-19-6-1/ensure-depends-on-for-mf.ts index 529020e6f2b66..5855489b63859 100644 --- a/packages/angular/src/migrations/update-19-6-1/ensure-depends-on-for-mf.ts +++ b/packages/angular/src/migrations/update-19-6-1/ensure-depends-on-for-mf.ts @@ -30,6 +30,12 @@ export default async function (tree: Tree) { const nxJson = readNxJson(tree); const nxMFDevRemotesEnvVar = 'NX_MF_DEV_REMOTES'; + const inputs = [ + ...(nxJson.namedInputs && 'production' in nxJson.namedInputs + ? ['production', '^production'] + : ['default', '^default']), + { env: nxMFDevRemotesEnvVar }, + ]; if ( !nxJson.targetDefaults || !nxJson.targetDefaults?.['@nx/angular:webpack-browser'] @@ -37,7 +43,7 @@ export default async function (tree: Tree) { nxJson.targetDefaults ??= {}; nxJson.targetDefaults['@nx/angular:webpack-browser'] = { cache: true, - inputs: ['production', '^production', { env: nxMFDevRemotesEnvVar }], + inputs, dependsOn: ['^build'], }; } else {