m0dch3n / vue-cli-plugin-cordova

Vue Cli 3 Cordova Plugin
MIT License
417 stars 63 forks source link

Don't modify src="…" in src-cordova/config.xml #63

Closed ssendev closed 5 years ago

ssendev commented 5 years ago

https://cordova.apache.org/docs/en/dev/config_ref/index.html mentions app/www/config.xml and plattform specific locations like app/platforms/android/res/xml/config.xml could the hook modify these files instead so that config.xml isn't constantly marked as changed? or is the timing wrong and it's not possible to get a hook that modifies these files at the right time.

m0dch3n commented 5 years ago

Sorry, I currently don't have the time, to test this, but you could give it a try for sure...

m0dch3n commented 5 years ago

Hey, thanks for your PR, but personally I don't like this template approach...

If prefer the idea, you mentioned above

So did you try, simply changing this line?

https://github.com/m0dch3n/vue-cli-plugin-cordova/blob/d46a8c0106ccbb976a9d90d02b408822b6932092/index.js#L110

ssendev commented 5 years ago

I have pushed an update that uses the original plan. But the android path is different than what's mentioned in the docs it's platforms/android/app/src/main/res/xml/config.xml since i don't have a mac i can't tell if the ios and osx paths are right. Like before browser dosn't need a config change so i omitted a browser path to avoid confusion.

Unfortunately it wasn't as easy as you suggested since in the prepare step the config is copied from config.xml to platforms/.../config.xml and undoes the change that was made before cordova run with a lot of trial and error (in part due to my stupidness) I was able to figure out that the before_prepare hook is executed after the config is overwritten and before it's read so i used that to overwrite the config.

Since cordova build and cordova prepare also reset the config i removed the config reverting on exit.

m0dch3n commented 5 years ago

Hi @ssendev thanks for your investigation and PR, I merged it and released it on 2.1.4.

1) I also did some adaptions, I removed the cordovaConfigPaths part, to keep backwards compatibility. So upgrading users, to need to do this manually.

I'm doing this on the fly during the serve command. To get VueExampleAppName, I'm simply parsing the config.xml

2) For ios and osxthe paths are same, so I adapted it.

3) Your <hook .../> was not added on a new project, as you place the code before the cordova create command