Skip to main content
Version: 0.15

Environment variable

Farm distinguishes between development and production environments through Farm process.env.NODE_ ENV`.

In different environments, environment variables are replaced statically, so use static constants to represent environment variables instead of dynamic expressions.

.env file

Farm uses dotenv to load your additional environment variables, such as .env files.

// .env
FARM_APP_SECRET=secret
Farm_APP_PASSWORD=password
APP_VERSION=1.0.0

Farm loads the file .env via dotenv, and loads it into process.env and finally injects it into define.

warning

In order to ensure the security of the client, preventing the environment variables in the current system from being exposed to the client Farm will only identify some important environment variables that start with FARM_VITE_ (In order to better compatible with vite and its ecological environment).

Farm expands environment variables through dotenv-expand

If you want to customize the prefix of env variables, you can configure envPrefix.

envPrefix

  • default value: FARM_VITE_

Customize the prefix of the env variable by configuring envPrefix.

Extremely Fast Web Build Tool Written in Rust

Copyright © 2024 Farm Community. Built with Docusaurus.