Good practice for env variables in Quasar v1, now that qenv / dotenv extensions are deprecated? #9318
Unanswered
davthedev
asked this question in
Quasar App Extensions
Replies: 2 comments 2 replies
-
|
@davthedev In the end it's just JavaScript. There are many ways you can do it. I would just write a script, then import that into quasar.conf.js and then apply it to |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Maybe that would be useful: Install dotenv package:
const DotEnv = require('dotenv')
const parsedEnv = DotEnv.config().parsed
module.exports = function () {
// Let's stringify our variables
for (key in parsedEnv) {
if (typeof parsedEnv[key] === 'string') {
parsedEnv[key] = JSON.stringify(parsedEnv[key])
}
}
return parsedEnv
}
const envparser = require('./config/envparser')
(...)
build: {
(...)
env: envparser(),
(...)
}Somewhere, in your code, test it with a .env variable: console.log( process.env.MY_ENV_VAR ); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
We had the dotenv / qenv extensions recommended to manage environment variables. They are deprecated since Apr 7.
It is noticed to use the env section of the quasar configuration file instead.
But I need to store environment-dependent variables, including API keys, which should not be present in version control. The quasar.conf.js file is not the right place for such information.
I was referenced to look at the updated doc in Quasar Next documentation, that directly recommends using the "real" dotenv, instead of the extensions. https://next.quasar.dev/quasar-cli/handling-process-env#using-dotenv
This one is related to v2, which is still in beta.
The situation is a bit confusing. I am stuck choosing between a deprecated solution (quasar-dotenv / qenv) and a beta one (v2). So I went on the quasar-dotenv route. It seems to work for now.
For a project that is due to go to production using the stable Quasar v1, which best practice you would recommend to manage environment variables today?
Beta Was this translation helpful? Give feedback.
All reactions