mhrabiee
mhrabiee

Reputation: 815

Missing .env in Vue CLI after run build

I'm building an app using Vue CLI 3. I've included .env in my project and everything works fine.

But when i'm building the app for production via npm run build there is no .env file in my dist folder, so i can't change my environmental variables in production server. Any solution or it's just fine?

Upvotes: 1

Views: 1985

Answers (2)

user14009051
user14009051

Reputation:

It is normal because application needed to be recompiled when .env file changed.

For convenience you can use .env.prod or .env.dev for your CI/CD pipeline.

Upvotes: 2

Saa
Saa

Reputation: 1615

This is supposed to happen. The env variables are embedded in your build.

You can make seperate .env files for production. These variables will be used during the production build.

Create a new .env file named: .env.production

Source: https://cli.vuejs.org/guide/mode-and-env.html#modes

Upvotes: 4

Related Questions