Closed eladcandroid closed 6 years ago
PS: For my commands I need to have different modes, otherwise the part with process.env.CORDOVA_PLATFORM, and the JSMiddleware are not working...
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...
Great!! Thanks a lot!
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
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 defaultAs loadEnv is first called with i.e. 'cordova-build-android', it is set to
development
already. Afterwards, when I call build, loadEnv, will not overrideprocess.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 exampleAnother 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...