Nuxt dotenv options require in nuxt-config.js doesn't work

aloiseau17
0
aloiseau17
commented a month ago

Hi,

I tried to use nuxt-dotenv with fileaname custom options like that:

modules: [
    ['@nuxtjs/dotenv', {
      filename: '.env.dev',
  }],
  ],

It's working fine in my app but not in my nuxt-config.js
I import dotenv at the top:

require('dotenv').config()

Before that I had to add the dotenv dependency to my package.json.
But the custom .env file wasn't read. Only .env is working.

0
aloiseau17
0
aloiseau17
commented 2 days ago

Ok, I just misunderstood the way to use .env inside nuxt-config.js

I just have to configure dot-env and not nuxtjs/dotenv when I require it inside nuxt-config.js
require('dotenv').config({ path: '.env.dev' })

0
Informations
Question โ€ข Unresolved
#c19 - Created a month ago