https://github.com/pagoru/electron-interceptor
https://github.com/pagoru/electron-interceptor
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pagoru/electron-interceptor
- Owner: pagoru
- License: mit
- Created: 2017-07-27T14:59:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-27T15:53:46.000Z (almost 9 years ago)
- Last Synced: 2025-11-10T01:31:42.711Z (9 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
This module is a simple `file` protocol interceptor for [electron](https://github.com/atom/electron) which compiles all (local) URLs to files with any extension to whatever you want.
[](https://www.npmjs.com/package/electron-interceptor) [](https://opensource.org/licenses/MIT)
# Installation
```
npm install electron-interceptor
```
# Usage
```js
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);
});
}
}
//...
]);
```