Giter Site home page Giter Site logo

cordova-plugin-browsersync's Introduction

Cordova Browser-Sync Plugin

Integrating BrowserSync into your Cordova workflow.

  • Watch files in the www folder and automatically reload HTML and CSS in all connected devices
  • Use BrowserSync's dashboard to control devices and reload them.
  • Synchronize scrolls, clicks and form inputs across multiple devices.
  • Supports real devices and emulators for iOS and Android platforms

Demo

Here is a blog post explaining the plugin and its internals.

Cordova Browser-Sync Plugin demo video

Usage

There are three ways to use the code in this plugin. Ensure that you have added the ws: and unsafe-inline CSP policies to your default-src section of the CSP meta tag (<meta content=...>) in index.html file.

Note that a -- --live-reload may need to be passed to cordova run command.

The presence of this --live-reload flag triggers the live reload workflow. Without this flag, the project remains unchanged. This way, the plugin does not have to be removed before packaging it for final deployment.

As a Cordova plugin (easiest)

This simplest way to integrate this in your Cordova workflow is to add it as a plugin

cordova plugin add cordova-plugin-browsersync

and then run run the cordova with cordova run -- --live-reload.

As a Cordova project hook

Clone this repo and run npm run createHook to get a after_prepare.js. Add this file as an after_prepare hook to your config.xml. For example:

<hook type="after_prepare" src="scripts/after_prepare.js" />

Integrate into your workflow

You can also require('cordova-plugin-browsersync') in your node module and use the changeHost function and browserSyncServer directly in your existing workflow.

Options

Ignoring files

In many cases other hooks may copy over JS, CSS or image assets into folders like www\lib, typically from locations like bower_components. These hooks may run at after_prepare and hence should be ignored in the live reload workflow. To achieve this, run the command as

cordova run -- --live-reload --ignore=lib/**/*.*

The --ignore commands takes an anymatch compatible destination relative to the www folder.

cordova-plugin-browsersync's People

Contributors

axemclion avatar csantanapr avatar fdim avatar nitinsurana avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.