const path = require("path");
const fs = require("fs");

// Loader entrypoint:
// - In dev: run the original source (electron/preload-src.js)
// - In packaged/prod: run the bundled/minified output (dist-electron/preload.cjs)

const distPreload = path.join(__dirname, "..", "dist-electron", "preload.cjs");
const isDev = process.defaultApp || /[\\/]electron(?:\.exe)?$/i.test(process.execPath);
const useDist = !isDev && fs.existsSync(distPreload);

require(useDist ? distPreload : "./preload-src");
