Skip to content

Add @ngx-env/builder to the list of builders #172

@chihab

Description

@chihab

First of all, thanks for this project. It was an inspiration and a good resource for me to build the @ngx-env/builder.

I suggest to add @ngx-env/builder 👇 to the list of builders.

Usage

  1. Add @ngx-env to your CLI project
ng add @ngx-env/builder
  1. Define Environment Variables in .env
NG_APP_ENABLE_ANALYTICS=false
NG_APP_VERSION=$npm_package_version
NG_APP_COMMIT=$GITHUB_SHA
  1. Use in TS and HTML
@Component({
  selector: "app-footer",
})
export class FooterComponent {
  version = process.env.NG_APP_VERSION;
  branch = process.env.NG_APP_BRANCH_NAME;
  commit = process.env.NG_APP_COMMIT;
  analyticsFlag = process.env.NG_APP_ENABLE_ANALYTICS;
}
<!-- Same output in the spans -->
<span> {{ 'process.env.NG_APP_BRANCH_NAME' | env }} </span>
<span> {{ 'NG_APP_BRANCH_NAME' | env }} </span>
<span> {{ branch }} </span>
<!-- index.html -->
<head>
  <title>NgApp on %NG_APP_BRANCH_NAME%</title>
</head>
  1. Run your CLI commands
npm start
NG_APP_BRANCH_NAME=$GITHUB_HEAD_REF ng test
NG_APP_BRANCH_NAME=`git branch --show-current` npm run build

Documentation

Links

And please let me know if you think about any good feature to add to the project. 💙

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions