Reputation: 46696
I don't want to follow the convention of putting my environment variable (.env
file) at the root directory of my Nuxt project.
How can I achieve another directory or even name for it without using the @nuxtjs/dotenv module? (I know this one is already baked into Nuxt since v2.13
and hence, not needed anymore).
Upvotes: 2
Views: 2488
Reputation: 389
I got no luck with the --dotenv
flag, so I'm just using replacing .env with the desired contents upon build or serve, like cp .env.xxx .env && yarn dev
.
Not the prettiest, but good enough.
In your case the command would be cp variables/.env_file .env && yarn dev
.
Upvotes: 1
Reputation: 46696
Looking at this answer: https://github.com/nuxt/nuxt.js/issues/8331#issuecomment-727533175
You can specify a different location and name if you'd like, with the following
yarn dev --dotenv variables/.env_file
With the following structure
Of course, this will work with yarn generate
and yarn build
.
Upvotes: 6