14
votes

i was trying to use live reload on my ionic 2 application. so i found this command

ionic run browser --live-reload

is not working as expected and while making code changes i am receiving console messages

[16:12:47]  build started ...
[16:12:47]  transpile update started ...
[16:12:47]  transpile update finished in 46 ms
[16:12:47]  deeplinks update started ...
[16:12:47]  deeplinks update finished in 248 ms
[16:12:47]  webpack update started ...

but the page isn't reloading

6
the syntaxis is ionic run browser --livereload. If it doesnt work, check the workarounds at github.com/driftyco/ionic-cli/issues/790Pablo Albaladejo
i tried ionic run browser --livereload but the same behavior. P.S. there isnt any workaround mentioned on that pagemanish kumar
workaround: after the change, wait until when the console shows the file changed and then rsync -rtv www/ platforms/browser/www or run another file watcher: fswatch -r www/ | xargs -I % rsync -rtv www/ platforms/browser/www workaround 2 ./node_modules/.bin/ionic-app-scripts serve --sourceMap source-map --iscordovaserve --wwwDir platforms/browser/www/ --buildDir platforms/browser/www/buildPablo Albaladejo

6 Answers

25
votes

i found the solution on the github page

include a script in the package.json file

"browser": "ionic-app-scripts serve --sourceMap source-map --iscordovaserve --wwwDir platforms/browser/www/ --buildDir platforms/browser/www/build"

and run

npm run browser
13
votes

When you run the command ionic cordova run browser --livereload you will see something like this in CLI:

[19:39:00]  dev server running: http://localhost:8100/ 

[INFO] Development server running
       Local: http://localhost:8100
       External: http://192.168.0.51:8100

Just open http://192.168.0.51:8100 or http://localhost:8100 and your live reload will work on that address. Your browser might have opened in http://localhost:8000 instead of 8100

4
votes

First off, should anyone need this answer, the command has been renamed in the later version to

ionic cordova run browser

Second, The --livereload flag is not supported when you run this command. this issue explains more

0
votes
Try This

ionic cordova run browser --livereload  --consolelogs --serverlogs
0
votes
"serve": "npx ionic serve --cordova --platform browser"
-1
votes

Using this command browser will be reloaded automatically.

ionic serve

If you want to run application with different platform in browser you can use this command :

ionic serve -l

This both command will reload page automatically on code change