i try to use environment variables in vue-cli, but is not working, everytime says 'undefined' when use console.log(process.env.VUE_APP_BASE_URI)
. But process.env.NODE_ENV
says 'development' as i defined in webpack.config.js.
I read the documentation of vue-cli 3 and put my .env.* files in the root project. like this:
Webpack.config.js
module.exports = {
mode: 'development',
context: __dirname,
entry: {
main: ['babel-polyfill', './App/index.js']
},
plugins:[
new VueLoaderPlugin()
],
.env.development
VUE_APP_BASE_URI=http://localhost:64208/api/
.env.production
VUE_APP_BASE_URI=http://localhost:64208/api/
I use .NET Core with Vue. How to use the environment?
it just happened to me, the solution is very simple. Just restart your development server.
ctrl + c
then
npm run serve