1.0.0 • Published 5 years ago

@legalshield/populate-env-vars v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

LegalShield populate-env-vars

Installation

npm install --save @legalshield/populate-env-vars

Environment Variable Syntax

<%= locals.SOME_ENVIRONMENT_VARIABLE %>

Usage

Just place an environment variable in a .template file using the above syntax and it will create a new file, with the injected environment variable(s), saved without the .template extension.

Currently the .template files have to be placed under ./src.

Example

The below index.html.template file would be saved as index.html.

<html>
  <title><%= locals.TITLE %></title>
  <body>
    <h1><%= locals.HEADER %></h1>
  </body>
</html>

Assuming the TITLE environment variable was set to My Title and the HEADER environment variable was set to My Header then it would be saved like the below.

<html>
  <title>My Title</title>
  <body>
    <h1>My Header</h1>
  </body>
</html>

Once this is installed in your node project, for instance an angular cli project, you can use it like below.

"scripts": {
    "build": "./node_modules/.bin/populate-env-vars && ./node_modules/.bin/ng build"
}
1.0.0

5 years ago