How can I use a Command to activate livereload in reload

1k views Asked by At

I'm trying to figure out what are the commands or ways to reload my browser platform on every change detected with ionic or cordova because for me this lineis not working:

ionic run browser --livereload

So I'm wondering if you know how to do that. I'm using cordova plugins by the way.

Kind regards!

3

There are 3 answers

8
Andreas Gassmann On

You can start your app in your browser with

ionic serve

This will refresh the app after every save. There were some build changes after the ionic rc2 release, so be sure to update to the latest version. That way it will even show you a loading toast, as well as give you a nicely formatted js error whenever your app fails to launch.

To update your project to the latest build version, update your package.json

{
  ...
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.47",
    "typescript": "2.0.9"
  }
}

You can find an example of a full package.json here: https://github.com/driftyco/ionic2-app-base

1
Rahul On

ionic serve is working fine for me. for browser, ionic serve detect every change in code and refresh the page.

You can find some commands here: https://ionicframework.com/docs/cli/serve/

0
andy owusu On

on Cli, you may try npm run dev too. --> Runs ionic serve ( development ). it's short, concise, gets the job done most times. give it a try