Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

A parcel plugin for generating Elm file for your env vars automatically.

License

Notifications You must be signed in to change notification settings

pablohirafuji/parcel-plugin-elm-env-vars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Parcel plugin for generating Elm file for your env vars automatically.

Installation

npm install parcel-plugin-elm-env-vars --dev

Parcel will use any installed package that begins with parcel-plugin- as plugin automatically.

Usage

By default, any env var starting with ELM_ and the NODE_ENV will be used.

You can customize this by creating a file called .parcel-plugin-elm-env-varsrc at the root of your package -- or creating an entry parcel-plugin-elm-env-vars in your package.json -- and set it following this structure, which is the default:

{
  "moduleName": "EnvVars",
  "vars": [
    "^NODE_ENV$",
    "^ELM_*"
  ]
}

No config file is watched. So you will need to restart the parcel server if you update the configuration.

By default, the file will be stored in a autogenerated folder at where parcel is being run at. At the moment it is not possible to customize the output folder.

Make sure to add the autogenerated folder to your elm.json file, e.g.:

{
  "type": "application",
  "source-directories": ["src", "autogenerated"],
  "elm-version": "0.19.0",
  ...
}

It is recommended to add the autogenerated folder to your .gitignore.

Example

With the default configuration, these env vars:

NODE_ENV='development'
ELM_API_ORIGIN='http://www.api.com'
RANDOM_SECRET='KJHa8s767as5&'

will generate this EnvVars.elm file:

module EnvVars exposing (..)

-- This file was autogenerated by parcel-plugin-elm-env-vars.
-- Do not edit it manually.


nodeEnv : String
nodeEnv =
    "development"


elmApiOrigin : String
elmApiOrigin =
    "http://www.api.com"

To also include the RANDOM_SECRET, add this var to your configuration.

About

A parcel plugin for generating Elm file for your env vars automatically.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published