electron-userland / electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
1.01k stars 99 forks source link

Add method to bypass the compilers completely #199

Closed MarshallOfSound closed 7 years ago

MarshallOfSound commented 7 years ago

Fixes https://github.com/electron-userland/electron-forge/issues/153

The reason I added this instead of a new bypass:// protocol or similar is because (on windows at least) the file path passed to the Electron protocol handler only works as expected on file:// not on any other URI's, it just get's completely messed up. This would seem to achieve what the above issue needs to so I think it's good enough for now :+1:.

Users can now just do this.

import { addBypassChecker } from 'electron-compile';

addBypassChecker((filePath) => {
  return /\.mp4/.test(filePath);
});

Or something similar, the more common use case might be a function like this (untested).

import { app } from 'electron';
import { addBypassChecker } from 'electron-compile';

addBypassChecker((filePath) => {
  return filePath.indexOf(app.getAppPath()) === -1;
});

Which would theoretically bypass electron-compile for all files not in the current app.

anaisbetts commented 7 years ago

This is still on my list

anaisbetts commented 7 years ago

I'm gonna merge this for now so that it doesn't get paved when I convert electron-compile to TypeScript

onassar commented 6 years ago

Where would one include this? I'm including it in one of my scripts, but I assume it needs to be located in a forge or compile script somewhere?

damienallen commented 5 years ago

Where would one include this? I'm including it in one of my scripts, but I assume it needs to be located in a forge or compile script somewhere?

I put in in index.ts but I don't think it matters so much. As far as I can tell it just has to be executed before any files needing the bypass are loaded.