Environment detection inside Vue / Framework 7

Hello,
i’ve read the following topic and in particular the linked answer: [SOLVED] How to detect the environment?

I’d like to know how can i inform my Vue/F7 instance of the environment, hence where to put that if (process.env.NODE_ENV === 'development') conditional.

Currently i’m using this (ugly, in my opinion) workaround, setting an ENV property on the global object and then reading it in my scripts:
image

How can i do better?

thanks!!!

This is just JS so you can use this expression directly in your JS process.env.NODE_ENV

1 Like

Damn i didn’t think it worked… i had tried logging process.env in my app.js and it was an empty object, but now i directly tried to log the NODE_ENV property and it was there.

image

That’s a mistery to me, but i’m happy it’s working.
Thanks!!

No mistery, this is how webpack works. It just replaces process.env.NODE_ENV everywhere in your code with development or production string

1 Like