electron-interceptor
v1.0.2
Published
This module is a simple interceptor for electron.
Downloads
5
Readme
This module is a simple file
protocol interceptor for electron which compiles all (local) URLs to files with any extension to whatever you want.
Installation
npm install electron-interceptor
Usage
const {BrowserWindow, app} = require('electron');
const pug = require('pug');
const less = require('less');
require('electron-interceptor')([
//Example with `.pug` extension to html
{
extension: '.pug',
mimeType: 'text/html',
exec: (content, callback) => {
callback(pug.render(content.toString(), {}));
}
},
//Example with `.less` extension to css
{
extension: '.less',
mimeType: 'text/css',
exec: (content, callback) => {
less.render(content.toString(), (error, compiled) => {
if(error){
callback(error);
return;
}
callback(compiled.css);
});
}
}
//...
]);