Skip to content

docs(templates/readme.md): updated environment variable section to El… #583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,12 @@ Passing the variables to your Elm-code can be done via `flags`:
// index.js
import { Main } from './Main.elm';

Main.fullscreen({
environment: process.env.NODE_ENV,
apiKey: process.env.ELM_APP_API_KEY
Elm.Main.init({
node: document.getElementById('root'),
flags: {
environment: process.env.NODE_ENV,
apiKey: process.env.ELM_APP_API_KEY
}
});
```

Expand All @@ -639,10 +642,17 @@ type alias Flags = { apiKey : String, environment : String }

init : Flags -> ( Model, Cmd Msg )
init flags =
...
...


main : Program Flags Model Msg
main =
programWithFlags { init = init, ... }
Browser.element
{ view = view
, init = init
, update = update
, subscriptions = always Sub.none
}
```

Be aware that you cannot override `NODE_ENV` manually. See
Expand Down