Code Monkey home page Code Monkey logo

cordova-plugin-livereload's Introduction

Deprecation notice

'cordova-plugin-livereload' has been deprecated!!!

Please use 'taco run --livereload' instead.

For more information please visit taco website.

cordova-plugin-livereload

This plugin's goal is to integrate livereload and gestures synchronization across devices into the Cordova development workflow. It is based on BrowserSync.

What it does :

  • Watch files in your www folder and automatically reload HTML and CSS in all connected devices

  • Synchronize scrolls, clicks and form inputs on multiple devices.

Supported platforms

  • Android
  • iOS

How to use it

It can be used in 2 ways:

  • As a cordova plugin
  • As an NPM package (you can include it in your custom workflows)

Using it as a plugin

  • Make sure your device/emulator and your computer are connected to the same wifi network

  • Install the plugin on your machine :

    cordova plugin add cordova-plugin-livereload

  • Create your cordova project :

    cordova create myProject

  • Navigate to your newly created project :

    cd myProject

  • Run your app with the --livereload flag, Note the extra --. This step launches the app on your device/emulator :

    cordova run android -- --livereload

  • Make changes to your HTML, CSS or Javascript and watch those changes instantaneously be reflected on your device/emulator

Options

  • Ignoring files

You can specify files to ignore with the --ignore=path option: This option accepts any anymatch-compatible definition. It defines files/paths to be ignored :

cordova run android -- --livereload --ignore=build/**/*.*

  • Local tunnel

In case you're facing connection issues due to proxy/firewall, you can use the --tunnel option:

cordova run android -- --livereload --tunnel

This option allows you to easily access the livereload server on your local development machine without messing with DNS and firewall settings. It relies on Localtunnel, which will assign you a unique publicly accessible url that will proxy all requests to your locally running development server.

  • ghostMode (Syncing across devices)

By default, gestures(clicks, scrolls & form inputs) on any device will be mirrored to all others. This option allows you to disable it if you want:

cordova run android ios -- --livereload --ghostMode=false

Using it as an NPM package

This codebase can also be used as an NPM package, making it easier to integrate in your custom workflows. Here's an example of how to use it:

   var lr = require('cordova-plugin-livereload');
   var cordova = require('cordova-lib');

   //  Start LiveReload server
   var projectRoot = '/home/omefire/Projects/mileage-tracker';
   var platforms = ['android', 'ios'];

   return lr.start(projectRoot, platforms, {
       ghostMode: true,
       ignore: 'build/**/*.*',
       cb: function (event, file, lrHandle) {
       
           // After a file changes, first run `cordova prepare`, then reload.
           cordova.raw.prepare().then(function () {
               var patcher = new lr.Patcher(projectRoot, platforms);
               return patcher.removeCSP();
           }).then(function () {
               if (event === 'change') {
                   return lrHandle.tryReloadingFile(file);
               }

               // If new files got added or deleted, reload the whole app instead of specific files only
               // e.g: index.html references a logo file 'img/logo.png'
               // deleting the 'img/logo.png' file will trigger a reload that will remove it from the rendered app
               // likewise, adding the 'img/logo.png' file will trigger it to be shown on the app
               return lrHandle.reloadBrowsers();
           }).fail(function (err) {
               var msg = ' - An error occurred: ' + err;
               logger.show(msg);
               lrHandle.stop();
           });
       }
    });




## LICENSE

cordova-plugin-livereload is licensed under the MIT Open Source license.

cordova-plugin-livereload's People

Contributors

joshuaskelton avatar nisheetjain avatar omefire avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cordova-plugin-livereload's Issues

Ignore capability

This option shall be used to specify the set of folders/files the user does not want to trigger livereload for those folders/files

Changing image file does not trigger reload

While testing with the stock Hello Cordova app on Android, I changed the contents of logo.png. The console noted the file change, but no reload was triggered. Changing another file (index.html) after changing the image did cause a reload and the new image to be reflected in the application.

Application error ERR_FILE_NOT_FOUND

Hi,

Am having an issue with livereload on an android device (haven't used an others) where after the app is installed to the phone (using "cordova run android -- --livereload") I get this alert:

Application Error
net::ERR_FILE_NOT_FOUND (file:///android_asset/www/homePage_0.5324000904802233omePage.html)

(assume the number is random)

If I do "cordova run android" it installs and runs fine.

Using

  • Windows 10
  • Node version v4.2.4
  • Cordova 5.4.1

Tested with blank install of cordova project and only plugin was livereload.

Tried to install as per the documentation, but running the "cordova plugin add cordova-plugin-livereload" line before the project was created created an error for me.

Any help would be appreciated to show me what I might be doing wrong.

Thanks very much,
Jarrod

livereload runs without explicitly using --livereload

Hi there,

First, thanks for a great plugin, a life saver!

I'm facing couple of issues:

  1. When launching the app using cordova run --device, i.e. without explicitly using --livereload, the plugin still runs. I'm on OS X, latest cordova and node version 4.2.

  2. CTRL+C doesn't seem to kill the livereload process, I have to manually kill it.

Option '--livereload' not recognized (ignoring).

I'm following exactly what you've posted on your readme.

The browser-sync loads up, but the files are not being watched. Even when I change the files, nothing happens in the browser-sync page (localhost:3000/3001)

This is the command I'm using to start:

cordova run android -- --livereload
Cordova CLI: 5.4.0
Gulp version:  CLI version 3.9.0
ios-deploy version: 1.8.2 
ios-sim version: 5.0.3 
OS: Mac OS X El Capitan
Node Version: v5.0.0
Xcode version: Xcode 7.1 Build version 7B91b 

On Windows 10, the plugin throws error: "Could not locate the bindings file"

When on Windows 10, the following error is thrown :

PS C:\Users\xyz\Desktop\test> cordova run android
ERROR running one or more of the platforms: Error: Could not locate the bindings file. Tried:
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\build\contextify.node
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\build\Debug\contextify.node
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\build\Release\contextify.node
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\out\Debug\contextify.node
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\Debug\contextify.node
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\out\Release\contextify.node
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\Release\contextify.node
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\build\default\contextify.node
→ C:\Users\xyz\Desktop\test\plugins\cordova-plugin-livereload\node_modules\jsdom\node_modules\contextify\compiled\0.12.2\win32\ia32\contextify.node
You may not have the required environment or OS to run this project
PS C:\Users\xyz\Desktop\test>

Gestures not synced across connected devices (Android + iOS)

Steps to repro:

  • connect an android device to your machine (via USB)
  • connect an iOS device to your machine (via USB)
  • create your project: cordova create myProj && cd myProj
  • acquire and install the plugin: cordova plugin add https://github.com/omefire/cordova-plugin-livereload.git
  • start livereloading: cordova run android ios --device -- --livereload
  • click, scroll and use input forms on one device

Expected:
clicks, scrolls and input forms should be relayed to all devices

Observed:
nothing happens

Dependencies get installed on every plugin addition

After the cordova-plugin-livereload gets installed once, its dependencies get installed on every other plugin addition.

Steps to reproduce:

Observed:
After adding the cordova-plugin-device, we see that livereload dependencies get installed, even though it's not the correct one.

Expected:
No livereload related dependencies get added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.