Search code examples
vue.jsenvironment-variablesweb-configvue-componentvue-cli

How to create multiple .env in vue.js


I am stuck in vue.js, how to manage multiple env for multiple servers like local, development and production ?


Solution

  • you can create different .env file for different environment like .env.development, .env.staging, and .env.production and in your package.json create build script like this -

    "scripts": {
    "build-dev": "vue-cli-service build --mode development --modern",
    "build-stage": "vue-cli-service build --mode staging --modern",
    "build-prod": "vue-cli-service build --mode production --modern",
    }
    

    For details please follow this doc https://cli.vuejs.org/guide/mode-and-env.html