m0dch3n / vue-cli-plugin-cordova

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

Relative path for cordova.js #115

Closed POLSEN2 closed 3 years ago

POLSEN2 commented 4 years ago

Hello. I'm using cordova across the browser, iOS & Android.

This plugin inserts cordova.js (absolute path) to index.html. When accessed through a different url in the brower (such as example.com/dir/hello), cordova.js cannot be found, because it is not relative to the root and this breaks the application.

What is the solution to change the public path to "./cordova.js" in the browser on serve and on build?

m0dch3n commented 4 years ago

The cordova.js is currently added here:

https://github.com/m0dch3n/vue-cli-plugin-cordova/blob/86c0330f8c178a385f8712e3a8619f633cea1f1f/index.js#L258-L264

Feel free, to do a PR

m0dch3n commented 4 years ago

And if I remember well, it is also related to my js middleware hack, I was required to do, because contentBase is not yet available under vue devserver...

https://github.com/vuejs/vue-cli/issues/5070#issuecomment-577057011

https://github.com/m0dch3n/vue-cli-plugin-cordova/blob/86c0330f8c178a385f8712e3a8619f633cea1f1f/index.js#L132-L147

jakguru commented 3 years ago

Hi,

I've encountered this error as well, and while i was testing i saw that simply setting publicPath: false on Line 263 fixed the issue for me (at least in my dev environment). Just curious what other negative impacts this might have, since so far it looks like it resolves it in both iOS and Browser.

(In my environment, i have the router set to history mode when running in browser environment, but otherwise its in hash, and I also specifically set publicPath in my vue.config.js)