Skip to content

davidemorotti/electron-protocol-serve

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

electron-protocol-serve

A file protocol that serves any existing file in a directory and redirects everything not found to index.html.

Made for ember-electron.

Usage

If you want to use it directly, you may do so at your own risk. Remember to register protocols and schemes before app.on('ready').

In your electron.js file:

const { app, protocol, BrowserWindow } = require('electron');
const protocolServe = require('electron-protocol-serve');

// Create the protocol
const filePath = 'path/to/your/dist/folder';
const protocolServeName = protocolServe({cwd: filePath, app, protocol });

// The protocol we created needs to be registered
protocol.registerStandardSchemes([protocolServeName], { secure: true });

// After registering protocol and schema, you can use it to serve your app to your window
app.on('ready', () => {
  mainWindow = new BrowserWindow();

  mainWindow.loadUrl('serve://dist'); // Will serve index.html from the folder you specified
});

API

See index.js.

Credits

About

Protocol used with ember-electron making it easier to work with assets.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%