{"flag":true,"single":true,"pageTitle":"Environment file in angular| variables, functions etc","post":{"id":106,"user_id":"1","slug":"environment-file-in-angular-variables-functions-etc-ipwe","title":"Environment file in angular| variables, functions etc","body":"<p>Using the Angular CLI, start by running the generate environments command shown here to create the src\/environments\/ directory and configure the project to use these files.<\/p>\r\n<pre class=\"language-markup\"><code>ng generate environments<\/code><\/pre>\r\n<p>The project's src\/environments\/ directory contains the base configuration file, environment.ts, which provides configuration for production, the default environment. You can override default values for additional environments, such as development and staging, in target-specific configuration files.<\/p>\r\n<p><strong>project\\src\\environments.ts<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>export const environment = {\r\n  production: false ,\r\n  domainURL: \"http:\/\/localhost:4200\",\r\n  site_details:{\r\n    title:\"My site\",\r\n    description:\"My site is awesome\"\r\n  }\r\n};<\/code><\/pre>\r\n<p>The main CLI configuration file, angular.json, contains a <strong>fileReplacements <\/strong>section in the configuration for each build target.<\/p>\r\n<pre class=\"language-markup\"><code>\"configurations\": {\r\n  \"development\": {\r\n    \"fileReplacements\": [\r\n        {\r\n          \"replace\": \"src\/environments\/environment.ts\",\r\n          \"with\": \"src\/environments\/environment.development.ts\"\r\n        }\r\n      ],\r\n      &hellip;<\/code><\/pre>\r\n<p>This means that when you build your development configuration with ng build --configuration development, the src\/environments\/environment.ts file is replaced with the target-specific version of the file, src\/environments\/environment.development.ts.<\/p>\r\n<p>You can add additional configurations as required. To add a staging environment, create a copy of src\/environments\/environment.ts called src\/environments\/environment.staging.ts, then add a staging configuration to angular.json:<\/p>","category_id":"13","is_private":"0","created_at":"2023-04-06T22:44:04.000000Z","updated_at":"2023-04-06T22:44:04.000000Z","category":{"id":13,"user_id":"1","name":"Angular","slug":"angular-rfjp","parent_id":"12","created_at":"2023-03-24T03:25:15.000000Z","updated_at":"2023-03-24T03:25:15.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"Using the Angular CLI, start by running the generate environments command shown here to create the src\/environments\/ directory and configure - Environment file in angular| variables, functions etc (Updated: April 6, 2023) - Read more about Environment file in angular| variables, functions etc at my programming site [SITE]","categories":[]}