The project has moved to the Nuxt-Community ๐ https://github.com/nuxt-community/dotenv-module
A nuxt.js module that loads your .env file into your context options
The module loads variables from your .env file directly into your nuxt.js application context
and process.env
.
- Add
nuxtjs-dotenv-module
dependency using yarn or npm to your project - Add
nuxtjs-dotenv-module
tomodules
section ofnuxt.config.js
{
modules: [
// Simple usage
'nuxtjs-dotenv-module',
// With options
['nuxtjs-dotenv-module', { /* module options */ }],
]
}
After creating your .env file in the project root, simply run your usual npm run dev
. The variable inside the .env file will be added to the context (context.env
) and process (process.env
)
if for some reason you want to restrict what's accessible into the context, you can can pass to the module options an only
array with the keys you want to allow.
{
modules: [
['nuxtjs-dotenv-module', {only: ['some_key']}],
]
}
Copyright (c) Julien Tant [email protected]