Hi all, this is my unofficial guide on how to use the quasar dotenv extension.
- Install the quasar app extension:
$ quasar ext add @quasar/dotenv
-
Follow the setup instructions, here you’ll specify the names for your production and development .env files ex:
dev.env // prod.env
-
Create files in your root directory based on the names specified in step (2)
// dev.env
FOO=bar
- You’re all set, you can access these vars in any file via
process.env.<var-name>
// src/components/example.vue
...
mounted() {
console.log(process.env.FOO)
},
...
For more information check out:
Why I wrote the post:
- This is very similar to the steps in the github repo but it wasn’t immediatley clear that I had to make new files and how the variables I specified would be accessible in my files.
If anythings missing feel free to correct me below / add to the knowledge of how to use this great framework