import * as esbuild from "esbuild"; import pkgInfo from "./package.json"; const VERSION = pkgInfo.version; const IS_DIST = process.argv.indexOf("--prod") !== -1 || process.argv.indexOf("-p") !== -1; const WS_URL = IS_DIST ? process.env.WS_URL : "ws://127.0.0.1:8787"; ////////////////////////////////////////////// console.log("VERSION", VERSION); console.log("IS_DIST", IS_DIST); console.log("WS_URL", WS_URL); await esbuild.build({ entryPoints: ["src/userscript/index.ts"], outfile: "dist/whatsapp-bridge.user.js", bundle: true, format: "iife", platform: "browser", target: "es2020", define: { __VERSION__: JSON.stringify(VERSION), __WS_URL__: JSON.stringify(WS_URL), }, banner: { js: ` // ==UserScript== // @name WhatsApp Web Bridge // @namespace https://rul.sh/ // @version ${VERSION} // @description WhatsApp Web WebSocket bridge // @match https://web.whatsapp.com/* // @updateURL https://git.rul.sh/khairul169/whatsapp-bridge/raw/branch/main/dist/whatsapp-bridge.user.js // @downloadURL https://git.rul.sh/khairul169/whatsapp-bridge/raw/branch/main/dist/whatsapp-bridge.user.js // @require https://github.com/wppconnect-team/wa-js/releases/download/nightly/wppconnect-wa.js // @grant none // @run-at document-idle // ==/UserScript== `, }, sourcemap: true, }); console.log("Built dist/whatsapp-bridge.user.js");