In a Vue 2 project, an environment variable (let it be VUE_APP_IMPORTANT_VAR
, for example) is mandatory, so I want to get a failed build if somebody has forgotten to specify the variable in .env
(or in another way). I tried this code:
/* main.js */
...
if (!process.env.VUE_APP_IMPORTANT_VAR) {
console.error("Critical: VUE_APP_IMPORTANT_VAR is not set")
throw 1
}
...
But this obviously gives successful build. So how do I break the build if the variable is not set?