ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - igorissen/angular-env-builder: Builder to generate "src/environments/environment.ts" file based on your environment variables
Builder to generate "src/environments/environment.ts" file based on your environment variables - igorissen/angular-env-builder
Visit Site

GitHub - igorissen/angular-env-builder: Builder to generate "src/environments/environment.ts" file based on your environment variables

GitHub - igorissen/angular-env-builder: Builder to generate "src/environments/environment.ts" file based on your environment variables

angular-env-builder

Build and test

Custom angular builder to generate "src/environments/environment.ts" file based on your environment variables.

Installation

npm install --save-dev @igorissen/angular-env-builder

You must install the dotenv package in version 16.4.x as it is a peer dependency.

npm install --save-dev [email protected]

Configuration

After installation, you need to configure the builder in your Angular project. Update your angular.json file to include angular-env-builder.

  1. Open the angular.json file in your project's root directory.
  2. Add the builder to the desired architect target
{
  // ...
  "projects": {
    "[your-app-name]": {
      "architect": {
        "[target-name]": {
          "builder": "@igorissen/angular-env-builder:generate",
          "options": {
            "destination": "src/environments/environment.ts",
            "variables": [
              {
                "envKey": "apiUrl",
                "processEnvKey": "API_URL",
                "valueType": "string"
              },
              {
                "envKey": "apiPayload",
                "processEnvKey": "API_PAYLOAD",
                "valueType": "object"
              },
              {
                "envKey": "apiPort",
                "processEnvKey": "API_PORT",
                "valueType": "number"
              },
              {
                "envKey": "apiEnabled",
                "processEnvKey": "API_ENABLED",
                "valueType": "boolean"
              }
            ]
          }
        }
      }
    }
  }
  // ...
}
  1. Replace [target-name] with the target you are customizing (e.g., build, serve, etc.), and provide necessary options as needed by the builder.

Builder Options

This table provides a structured overview of each property and its intended type and purpose within the options object.

Property Type Description
destination string The file path where the environment variables will be written.
variables array of objects An array containing objects that define each environment variable to process.

Each object within the variables array has the following properties:

Property Type Description
envKey string The key to be used in the output environment file (environment.ts) to access the environment variable.
processEnvKey string The key used to reference the environment variable from the Node.js process (process.env).
valueType string The expected data type of the environment variable value. It can be string, object, number, or boolean.

Usage

Once configured, you can run the builder using Angular CLI:

ng run [project-name]:[target-name]

Replace [project-name] with the name of your Angular project and [target-name] with the target you configured.

Support

If you encounter any issues, feel free to create an issue.

License

This project is licensed under the MIT License - see the LICENSE file for details.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory