From c2be7350971c3e18b223e5b93b85b18188cd51f1 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Fri, 20 Jan 2023 18:34:26 +0200 Subject: [PATCH] fix(vite): remove environments generation (#14515) --- packages/react/src/generators/application/application.ts | 8 +++++++- .../web/src/generators/application/application.spec.ts | 6 +----- packages/web/src/generators/application/application.ts | 8 +++++++- .../app-vite/src/environments/environment.prod.ts__tmpl__ | 3 --- .../app-vite/src/environments/environment.ts__tmpl__ | 6 ------ 5 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 packages/web/src/generators/application/files/app-vite/src/environments/environment.prod.ts__tmpl__ delete mode 100644 packages/web/src/generators/application/files/app-vite/src/environments/environment.ts__tmpl__ diff --git a/packages/react/src/generators/application/application.ts b/packages/react/src/generators/application/application.ts index 1225554cd60a7..e8fda83121cdd 100644 --- a/packages/react/src/generators/application/application.ts +++ b/packages/react/src/generators/application/application.ts @@ -103,7 +103,13 @@ export async function applicationGenerator(host: Tree, schema: Schema) { const { viteConfigurationGenerator } = await import('@nrwl/vite'); // We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development. // See: https://vitejs.dev/guide/env-and-mode.html - host.delete(joinPathFragments(options.appProjectRoot, 'src/environments')); + if ( + host.exists(joinPathFragments(options.appProjectRoot, 'src/environments')) + ) { + host.delete( + joinPathFragments(options.appProjectRoot, 'src/environments') + ); + } const viteTask = await viteConfigurationGenerator(host, { uiFramework: 'react', diff --git a/packages/web/src/generators/application/application.spec.ts b/packages/web/src/generators/application/application.spec.ts index 6129d93e3255e..6393001df86c8 100644 --- a/packages/web/src/generators/application/application.spec.ts +++ b/packages/web/src/generators/application/application.spec.ts @@ -1,9 +1,5 @@ import { installedCypressVersion } from '@nrwl/cypress/src/utils/cypress-version'; -import { - NxJsonConfiguration, - readProjectConfiguration, - Tree, -} from '@nrwl/devkit'; +import { readProjectConfiguration, Tree } from '@nrwl/devkit'; import { getProjects, readJson } from '@nrwl/devkit'; import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing'; diff --git a/packages/web/src/generators/application/application.ts b/packages/web/src/generators/application/application.ts index 96c42e963084f..b50b4ee1ba40e 100644 --- a/packages/web/src/generators/application/application.ts +++ b/packages/web/src/generators/application/application.ts @@ -199,7 +199,13 @@ export async function applicationGenerator(host: Tree, schema: Schema) { const { viteConfigurationGenerator } = require('@nrwl/vite'); // We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development. // See: https://vitejs.dev/guide/env-and-mode.html - host.delete(joinPathFragments(options.appProjectRoot, 'src/environments')); + if ( + host.exists(joinPathFragments(options.appProjectRoot, 'src/environments')) + ) { + host.delete( + joinPathFragments(options.appProjectRoot, 'src/environments') + ); + } const viteTask = await viteConfigurationGenerator(host, { uiFramework: 'none', diff --git a/packages/web/src/generators/application/files/app-vite/src/environments/environment.prod.ts__tmpl__ b/packages/web/src/generators/application/files/app-vite/src/environments/environment.prod.ts__tmpl__ deleted file mode 100644 index 3612073bc31cd..0000000000000 --- a/packages/web/src/generators/application/files/app-vite/src/environments/environment.prod.ts__tmpl__ +++ /dev/null @@ -1,3 +0,0 @@ -export const environment = { - production: true -}; diff --git a/packages/web/src/generators/application/files/app-vite/src/environments/environment.ts__tmpl__ b/packages/web/src/generators/application/files/app-vite/src/environments/environment.ts__tmpl__ deleted file mode 100644 index d9370e924b51b..0000000000000 --- a/packages/web/src/generators/application/files/app-vite/src/environments/environment.ts__tmpl__ +++ /dev/null @@ -1,6 +0,0 @@ -// This file can be replaced during build by using the `fileReplacements` array. -// When building for production, this file is replaced with `environment.prod.ts`. - -export const environment = { - production: false -};