How to Access Environment Variables in a Makefile
How can we access environment variables inside our
Suppose this is our project structure.
📂 project ┣ 📜 Makefile ┗ 📜 .env
Makefile doesn’t automatically have access to the root
.env file, which might look something like this.
# .env HOSTNAME=localhost PORT=3000
That said, we can
include the appropriate environment file in our
# Makefile include .env URI:=$(HOSTNAME):$(PORT)
The environment variables are then accessible using the