1

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?

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.