Pages
Introduction
Getting Started
Recipes
Reference
Literals
Arrays
Tuples
Type System
Functions
Modules
Records
Enums
Built-in Types
Constants
Equality
Stores
Routing
Comments
Control Expressions
Components
Properties
Computed Properties
Styling Elements
Connecting Stores
Using Providers
Internal State
Referencing Entities
Global Components
Lifecycle Functions
Directives
JavaScript Interop
Environment Variables
Packages
Environment Variables
When building web applications usually the same application needs to work in different environments (development, staging, production). There are some variables like API endpoints that differ depending on the environment.
Mint offers a simple feature for managing these variables. You can create
different files
.env
and
.env.production
which have contents like this:
ENDPOINT=http://localhost:3001
WSENDPOINT=ws://localhost:3001
Then in Mint code you can inline them:
component Main {
fun render : Html {
<div>
<{ @ENDPOINT }>
</div>
}
}
Specifying .env file
The Mint CLI
has a global flag
-e
or
--env
which takes the path to the
.env
file:
mint start --env .env.production