Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is process.env.BASE_URL in vue js?

Tags:

vue.js

When I manually selected presets when installing vue using vue cli. I stumbled upon process.env.BASE_URL. I was tryng to find it in the internet but to no avail, I can't find any decent explanation. Here's the code.

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
like image 590
Errol Paleracio Avatar asked Nov 05 '19 02:11

Errol Paleracio


People also ask

What is env file in VUE JS?

This is a quick tutorial on how to create and access environment variables in Vue 3 with a dotenv ( . env ) file. Vue 3 apps built with Vite support dotenv environment variables out of the box, so all you need to do is add a . env file to the root folder of your Vue project.

What is process env in node JS?

In Node. js, process. env is a global variable that is injected during runtime. It is a view of the state of the system environment variables. When we set an environment variable, it is loaded into process.

How do I see process env in react?

You can access it from process. env. NODE_ENV . This variable changes based on what mode you are currently in.

What is VUE CLI service?

The CLI ( @vue/cli ) is a globally installed npm package and provides the vue command in your terminal. It provides the ability to quickly scaffold a new project via vue create . You can also manage your projects using a graphical user interface via vue ui .


1 Answers

the documentation is here https://cli.vuejs.org/guide/mode-and-env.html#environment-variables

It has a system of cascading files that will determine enviroment variables for your app. The main file being a .env

The BASE_URL is semi arbitary, you could introduce your own BASE_ROUTER_URL variable if you wanted

like image 113
Keith Nicholas Avatar answered Sep 23 '22 16:09

Keith Nicholas