-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment Variables #787
Comments
Hello, your issue has been closed because it does not conform to our issue requirements. In order to ensure every issue provides the necessary information for us to investigate, we require the use of the Issue Helper when creating new issues. Thank you! |
Use There will be more documentation on this soon. |
Thanks dude, But how can I replace BASE_URL? |
As Evan just told you: Use a
|
module.exports = {
baseUrl: '/foo'
} |
I know what is that. Actually, .env file just allow variables that starts with VUE_APP_ ;) |
Hello, When in In Object({
NODE_ENV: "production"
}) I read about the Thanks |
Thanks @phoet in the end I made it work with the change below in module.exports = {
configureWebpack: {
...,
plugins: [
new webpack.DefinePlugin({
'process.env': {
'GIT_COMMIT': JSON.stringify(process.env.GIT_COMMIT),
'GIT_BRANCH': JSON.stringify(process.env.GIT_BRANCH)
}
})
]
}
} And then using it like |
I have done another thing that probably is not really good but it works too. In
And in
|
@yyx990803 Dear Evan, after reaching to this issue report, I realized I'm also think, the README is a bit misleading. Do you think it would be easier, if Vue client could internally first looks |
Does support for .env[mode][local] require we add dotenv library? I have a .env.development file in my app root with an environment variable using the VUE_APP_ prefix and it does not get loaded. |
No dotenv required I see:
Sorry, I was not running with the right mode to load my .env.development file. ie |
I've been looking for this information around but could not find it. If I create a real env variables (during my Gitlab pipeline for example) such as .env files should never contain sensible data, and thus sensible data should be provided by Jenkins/Gitlab/etc. It's not clear if the |
Existing env variables have highest priority. |
Sadly, after testing it seems it is not the case.
|
We need this in DOC 🤔 |
@RDeluxe Hard to make anything from such a blanket statement. Can you provide a reproduction? Also, maybe you simply aren't on the latest version? We only fixed this in the last beta before RC or something. @cbo317110 That would make sense, yet. |
Sorry. The repro is quite simple :
We are using |
You shouldn't do this. |
We introduced .env file so you don't have to do this, why would you?
... and we changed priority for env variables in beta.16: https://github.com/vuejs/vue-cli/blob/dev/CHANGELOG.md#300-beta16-2018-06-08
|
Sorry, just a reflex, does not change anything in the end I guess, but the behavior was the same anyway, and it seems the explanation was simply the version we were using ! Thanks. |
We are deploying vue-cli3 app od Digital Ocean trough Laravel Forge and the We have followed this guide as well https://alligator.io/vuejs/using-new-vue-cli-3/#environment-variables but we can not find the solution. UPDATE: we have now reconfigured NGINX website eon the production server to show to |
This worked really well for me..But it would be great if there's a way in which variables can be directly read from .env file. |
But there is, we have a big section about it in the docs |
Now it's in the doc.see here.Thanks @LinusBorg for letting me know about that. |
It has always been in the docs. |
dfb2583#diff-eed3c9cd8ce5593f9de87fdeab03be11R33 |
I have the following in a .env file in the root of my project
When I do console.log(process.env) in my App.vue file, I don't see the variables This is the output
Any idea why vue might not be loading my environment variables? |
I am having the same issue. It's getting a little frustrating |
Didn't you try this? #787 (comment) |
@yyx990803 Hey Evan, how can I tell my Is this possible?
EDIT: So, I found this From this, I could clearly see that there's no easy way to make
It does exactly what I wanted, but not sure if there's a cleaner or better approach. Please let me know, whoever sees this and @ at me! Thanks! |
I tried this [#787 (comment)(https://github.com//issues/787#issuecomment-390899673) but it was not working.... |
I tried to stop node server and restarted node server...
of course, after editing vue.config.js and it is working fine... |
How can I configure my environment variables in this new cli? For example, BASE_URL, ENDPOINT_API?
Thanks.
The text was updated successfully, but these errors were encountered: