Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In prod script: process.env.NODE_ENV === "production" returns false #17

Closed
eladcandroid opened this issue Oct 7, 2018 · 5 comments
Closed

Comments

@eladcandroid
Copy link

No description provided.

@m0dch3n
Copy link
Owner

m0dch3n commented Oct 8, 2018

After investigating into this, I found the problem, it comes from loadEnv in vue cli Service...

This method checks if there are .env files like .env.cordova-build-android, and if not, it sets process.env.NODE_ENV to development by default

As loadEnv is first called with i.e. 'cordova-build-android', it is set to development already. Afterwards, when I call build, loadEnv, will not override process.env.NODE_ENV anymore, because it's not null.

So one solution would be, to create .env.cordova-build-android, and put there NODE_ENV=production, like in their staging example

Another solution, would be maybe, that I unset process.env.NODE_ENV before I run build, however this would unset any setting from the .env.cordova-build-android file.

I would need to test this more, I think, if the .env.cordova-build-platform doesn't exist, there's no problem to unset it, or if it exists, I need to check, if NODE_ENV is set, in this file...

However I personally don't like this second solution much, because it's more a work around the problem from loadEnv...

@m0dch3n
Copy link
Owner

m0dch3n commented Oct 8, 2018

PS: For my commands I need to have different modes, otherwise the part with process.env.CORDOVA_PLATFORM, and the JSMiddleware are not working...

@m0dch3n
Copy link
Owner

m0dch3n commented Oct 8, 2018

I created a feature request for the cli, because I think, this is the best solution IMO.

In the meantime, you can add the specific .env.cordova-build-platform files...

@eladcandroid
Copy link
Author

Great!! Thanks a lot!

@4lyn
Copy link

4lyn commented Oct 31, 2018

FWI it also allows you to build using different mode
vue-cli-service cordova-build-android --mode staging
That was not possible with the previous version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants