All Projects → nuxt-community → Dotenv Module

nuxt-community / Dotenv Module

Licence: mit
Loads your .env file into your application context

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Dotenv Module

Nuxt7
📱 Full Featured iOS & Android PWA Apps with Nuxt.js and Framework7
Stars: ✭ 282 (-34.27%)
Mutual labels:  nuxt
Router Module
Nuxt.js module to use router.js instead of pages/ directory.
Stars: ✭ 322 (-24.94%)
Mutual labels:  nuxt
Sync Dotenv
Keep your .env in sync with .env.example
Stars: ✭ 393 (-8.39%)
Mutual labels:  dotenv
Nuxt Property Decorator
Property decorators for Nuxt (base on vue-property-decorator)
Stars: ✭ 293 (-31.7%)
Mutual labels:  nuxt
Blog Front
blog-front @nuxt
Stars: ✭ 305 (-28.9%)
Mutual labels:  nuxt
Vue Notion
A fast Vue renderer for Notion pages
Stars: ✭ 343 (-20.05%)
Mutual labels:  nuxt
Nuxt Ssr Firebase
Nuxt.js Universal App with SSR via Firebase Functions and Firebase Hosting
Stars: ✭ 273 (-36.36%)
Mutual labels:  nuxt
Vue Gallery
📷 Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
Stars: ✭ 405 (-5.59%)
Mutual labels:  nuxt
Nuxt Material Admin
Vue-CLI Boilerplate based on Nuxt and vue-material-admin template.
Stars: ✭ 310 (-27.74%)
Mutual labels:  nuxt
Python Dotenv
Get and set values in your .env file in local and production servers. 🎉
Stars: ✭ 4,533 (+956.64%)
Mutual labels:  dotenv
Graphcms Examples
Example projects to help you get started with GraphCMS
Stars: ✭ 295 (-31.24%)
Mutual labels:  nuxt
Nuxt Elm
基于nuxt2+vue构建的全栈开源项目
Stars: ✭ 304 (-29.14%)
Mutual labels:  nuxt
Nuxt Purgecss
Drop superfluous CSS! A neat PurgeCSS wrapper for Nuxt.js
Stars: ✭ 356 (-17.02%)
Mutual labels:  nuxt
Dotenv
Symfony Dotenv parses .env files to make environment variables stored in them accessible via getenv(), $_ENV, or $_SERVER.
Stars: ✭ 3,268 (+661.77%)
Mutual labels:  dotenv
Awesome Nuxt
A curated list of awesome things related to Nuxt.js
Stars: ✭ 4,285 (+898.83%)
Mutual labels:  nuxt
Nuxt Blog
基于Nuxt.js服务器渲染(SSR)搭建的个人博客系统
Stars: ✭ 277 (-35.43%)
Mutual labels:  nuxt
Dotenv Kotlin
🗝️ Dotenv is a module that loads environment variables from a .env file
Stars: ✭ 326 (-24.01%)
Mutual labels:  dotenv
Pgsh
Branch your PostgreSQL Database like Git
Stars: ✭ 428 (-0.23%)
Mutual labels:  dotenv
Nuxtent Module
Seamlessly use content files in your Nuxt.js sites.
Stars: ✭ 399 (-6.99%)
Mutual labels:  nuxt
Koa Template
Starter template for Nuxt.js with KoaJS.
Stars: ✭ 374 (-12.82%)
Mutual labels:  nuxt

@nuxtjs/dotenv

npm version npm downloads Circle CI Codecov License

A Nuxt.js module that loads your .env file into your context options

📖 Release Notes

⚠️ With Nuxt v2.13 you might want to migrate from @nuxtjs/dotenv module to use the new runtime config.

Features

The module loads variables from your .env file directly into your nuxt.js application context and process.env.

Setup

  1. Add @nuxtjs/dotenv dependency to your project
yarn add --dev @nuxtjs/dotenv # or npm install --save-dev @nuxtjs/dotenv
  1. Add @nuxtjs/dotenv to the buildModules section of nuxt.config.js

⚠️ If you are using a Nuxt version previous than v2.9 you have to install module as a dependency (No --dev or --save-dev flags) and also use modules section in nuxt.config.js instead of buildModules.

export default {
  buildModules: [
    // Simple usage
    '@nuxtjs/dotenv',

    // With options
    ['@nuxtjs/dotenv', { /* module options */ }]
  ]
}

Using top level options

export default {
  buildModules: [
    '@nuxtjs/dotenv'
  ],
  dotenv: {
    /* module options */
  }
}

Options

only

  • Type: Array[String]
  • Default: null

If you want to restrict what's accessible into the context, you can pass to the module options an only array with the keys you want to allow.

export default {
  buildModules: [
    ['@nuxtjs/dotenv', { only: ['some_key'] }]
  ]
}

path

  • Type: String
  • Default: srcDir

By default, the we'll be loading the .env file from the root of your project. If you want to change the path of the folder where we can find the .env file, then use the path option.

export default {
  buildModules: [
    ['@nuxtjs/dotenv', { path: '/path/to/my/global/env/' }]
  ]
}

Note: that this is the path to the folder where the .env file live, not to the .env file itself.

The path can be absolute or relative.

systemvars

  • Type: Boolean
  • Default: false

By default this is false and variables from your system will be ignored. Setting this to true will allow your system set variables to work.

export default {
  buildModules: [
    ['@nuxtjs/dotenv', { systemvars: true }]
  ]
}

filename

  • Type: String
  • Default: .env

We can override the filename when we need to use different config files for different environments.

export default {
  buildModules: [
    ['@nuxtjs/dotenv', { filename: '.env.prod' }]
  ]
}

Usage

After creating your .env file in the project root, simply run your usual yarn dev or npm run dev. The variable inside the .env file will be added to the context (context.env) and process (process.env).

Using .env file in nuxt.config.js

This module won't overload the environment variables of the process running your build.

If you need to use variables from your .env file at this moment, just prepend require('dotenv').config() to your nuxt.config.js:

require('dotenv').config()

export default {
  // your usual nuxt config.
}

This will works thanks to the dotenv library provided by this module as a dependency. If you decided to ignore some values from your .env file in the module configuration, this won't apply here.

License

MIT License

Copyright (c) Nuxt Community

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].