Giter Club home page Giter Club logo

electron-reload's Introduction

electron reload

This is (hopefully) the simplest way to load contents of all active BrowserWindows within electron when the source files are changed.

Neutron Compatible NPM Version license

Disclaimer: this module is in its very early stages and the logic is still not mature enough.

Installation

npm install electron-reload

Usage

Just initialize this module with desired glob or file path to watch and let it refresh electron browser windows as targets are changed:

'use strict';

const {app, BrowserWindow} = require('electron');

require('electron-reload')(__dirname);

// Standard stuff
app.on('ready', () {
  let mainWindow = new BrowserWindow({width: 800, height: 600});

  mainWindow.loadUrl(`file://${__dirname}/index.html`);
  // the rest...
});

Not that the above code only refreshes WebContents of all BrowserWindows. So if you want to have a hard reset (starting a new electron process) you can just pass the path to the electron executable in the options object. For example if you already have electron pre-built installed you could just do

require('electron-reload')(__dirname, {
  electron: require('electron-prebuilt')
});

API

electron_reload(paths, options)

  • paths: a file, directory or glob pattern to watch
  • options (optional): chokidar options plus electron property pointing to electron executables. (default: {ignored: /node_modules|[\/\\]\./})

Why this module?

Simply put, I was tired and confused by all other available modules which are so complicated* for such an uncomplicated task!

* e.g. start a local HTTP server, publish change events through a WebSocket, etc.!

Even more!

If you want to have least effort when developing electron packages, take a look at neutron!

Changelog

  • 1.0.0: Adapt to Electron 1.0 new API
  • 0.3.0: Use new method of accessing app (e.g. require(electron).app)
  • 0.2.0: Use new electrons (> v0.32.3) browser-window-created event

electron-reload's People

Contributors

louisgv avatar yan-foto avatar

Watchers

 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.