After creating my Vue application using vue/cli
with the command vue create my-vue
, I decided to build the project in next
mode. Following the steps outlined in the Vue documentation, I created a .env.next
file at the root of the project with the following content:
FOO=next
Upon checking the value of FOO
in my main.js
file, I noticed that it returned as undefined. This left me puzzled as to why this was happening.
Subsequently, I proceeded to run the build process with the command:
npm run build -- --mode next
However, upon running the resulting dist folder in the console, I found that the value for FOO
continued to be undefined. Further investigation revealed that the term "next" was not present in the bundle.
This begs the question: Why are environment variables defined in .env
files not being utilized in the build output? How can I resolve this issue?