piral-cli-dotenv v1.0.0
piral-cli-dotenv
Plugin for the piral-cli. Adds a flag to include environment variables from .env files.
Extends the Piral CLI command options to include dotenv files.
Installation
Install the plugin either locally or globally.
We recommend the local installation:
npm i piral-cli-dotenv --save-devUsage
Including a .env File
Some commands of the Piral CLI will be extended with --env flags, e.g.,
piral debug <regular options> --envThe list of supported / extended commands is:
build-piraldebug-piralvalidate-piralbuild-piletdebug-piletpublish-piletvalidate-pilet
The --env flags behave as follows.
No argument
Standard dotenv resolution mechanism, e.g., takes a .env file if available.
Example Call:
piral build <regular options> --envFile path
Uses the path to resolve and use the file as dotenv input.
Example input:
./secrets/.envExample call:
piral build <regular options> --env .env.prodName
Uses a file {name}.env or .env.{name} as input for dotenv.
Example input:
prodExample call:
piral build <regular options> --env prodVariables
Uses the provided values as environment variables.
Example inputs:
FOO=BAR
FOO="BAR";BAR="FOO"Example call:
piral build <regular options> --env SERVICE_URL="http://example.com"FAQ
Does it work with every bundler?
Yes.
Are some environment variables overwritten?
Yes. Some variables are special (e.g., NODE_ENV) and will be set by the piral-cli anyway. This plugin focuses on non-special variables.
License
This plugin is released using the MIT license. For more information see the LICENSE file.