npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@igorissen/angular-env-builder

v1.0.0

Published

Builder to generate "src/environments/environment.ts" file based on your environment variables

Downloads

10

Readme

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.