Search code examples
vue.jsenvironment-variablesproduction-environmentvue-cli-3

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?


Solution

  • 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