m0dch3n / vue-cli-plugin-cordova

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

cordova-serve-ios doesn't copy files to www #76

Closed alexcroox closed 5 years ago

alexcroox commented 5 years ago

I have an issue where my app isn't updating in response to changes I make in code. For example I add an extra character to a word but I don't see the change in the app. Even after quitting the app and re-running vue-cli-service cordova-serve-ios.

So I tried clearing out src-cordova/www/js in case it was struggling to overwrite the files. However re-running vue-cli-service cordova-serve-ios doesn't seem to be copying over any files to www/js. At what stage is this supposed to happen?

 DONE  Compiled successfully in 22204ms                                                                                                               12:09:49 PM

  App running at:
  - Local:   https://localhost:8080
  - Network: https://192.168.18.78:8080

  Note that the development build is not optimized.
  To create a production build, run npm run build.

 INFO  executing "cordova clean" in folder /Users/alex/Projects/hectare-src/app/src-cordova
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/Users/alex/Library/Android/sdk (recommended setting)
ANDROID_HOME=/Users/alex/Library/Android/sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

BUILD SUCCESSFUL in 0s
3 actionable tasks: 3 up-to-date
Running command: xcodebuild -project SellMyLivestock.xcodeproj -configuration Debug -alltargets clean
note: Using new build system

** CLEAN SUCCEEDED **

Running command: xcodebuild -project SellMyLivestock.xcodeproj -configuration Release -alltargets clean
note: Using new build system

** CLEAN SUCCEEDED **

 INFO  executing "cordova run ios" in folder /Users/alex/Projects/hectare-src/app/src-cordova
Reading build config file:
Building project: /Users/alex/Projects/hectare-src/app/src-cordova/platforms/ios/SellMyLivestock.xcworkspace
    Configuration: Debug
    Platform: device
    Target:
Adding xcodebuildArg: -UseModernBuildSystem=0
m0dch3n commented 5 years ago

This is documented in the REAMDE, basically cordova-serve-ios does :

so hot reload is done by vue, try if your hot reload does work, without cordova, just by running npm run serve

alexcroox commented 5 years ago

Yeah I was reading the README and the only mention of www coping outside production builds is during installation it seems? Does that mean first installation copies your assets across, and even if they are 4 months out of date, during serve the most up to date assets are always loaded from the active development server?

So my recommended course of action for now is to run npm run cordova-build-only-www-ios and try serve again?

m0dch3n commented 5 years ago

copying to cordova/www is only done during a build, otherwise your app is served by the dev server of vue cli...

cordova is just a webview, so just a browser, showing the dev webpage during serve... if hot reload is not working, make sure, your webview is showing the dev webpage, and not the files from www folder...

this plugin adapts the content of your config.xml therefore...

m0dch3n commented 5 years ago

so during development it doesn't matter what's inside www folder, the folder can even be empty...

alexcroox commented 5 years ago

Thanks for the clarification. I'll have to check my config.xml as emptying out the www folder completely breaks the app for me so it must be trying to load from there.

alexcroox commented 5 years ago

Think I see the issue

<content src="index.html" />
<allow-navigation href="http://192.168.18.78:8080" />

I'm guessing somethings fallen out of sync as I seem to remember this plugin updating these values and then reverting them when the process is closed. I don't see any change to these during run now.

alexcroox commented 5 years ago

I've upgraded this plugin, could you let me know what my config.xml should be before I run any of your commands?

I believe:

<content src="index.html" />
<hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" />

but I don't see a allow-navigation tag being injected which your source seems to indicate would happen.

alexcroox commented 5 years ago

This is now working. I had to set

devServer: {
    https: false
  }

in vue.config.js. I know you mentioned it in README, but not the workaround if you aren't ready for https locally.

m0dch3n commented 5 years ago

https should work with cordova 8 or later

waliente commented 5 years ago

This is now working. I had to set

devServer: {
    https: false
  }

in vue.config.js. I know you mentioned it in README, but not the workaround if you aren't ready for https locally.

i do that and now works also for me!