Electron changing the root


I want to have electron use the web root rather than the filesystem root. So, for example:

would become: or: import module from "/scripts/directives/module.js" would become: import module from "/home/user/Documents/web/crucible/app/scripts/directives/module.js" Essentially prepending the path that "npm start" was called from to each filepath that starts with a /. Real websites do this automatically (ish), but I'm not sure how to handle it in Electron. I tried to follow [these instructions](https://github.com/electron/electron/issues/2242) and use fileInterceptProtocol to do it, but I got "Error: the scheme has been intercepted". When I researched that, it turned out that I can't use fileInterceptProtocol because electron-prebuilt-compile is already using it. I also tried defining a WEB_ROOT variable in main.js (the file that gets passed to Electron) but when I tried to use it in other js/html files, it said it wasn't defined. Any suggestions? It's pretty painful to have long strings of "../../.." before every filepath, and it makes the entire project very fragile and difficult to refactor if I need to later.