All checks were successful
check / check (push) Successful in 22s
Replace stub wordlist with ethers.Mnemonic.fromEntropy() using crypto.getRandomValues(). Add esbuild to bundle popup JS so it can import ethers directly — no background messaging needed. Each die click now generates a valid, random BIP-39 mnemonic.
92 lines
2.9 KiB
JavaScript
92 lines
2.9 KiB
JavaScript
const fs = require("fs");
|
|
const path = require("path");
|
|
const { execSync } = require("child_process");
|
|
const esbuild = require("esbuild");
|
|
|
|
const DIST_CHROME = path.join(__dirname, "dist", "chrome");
|
|
const DIST_FIREFOX = path.join(__dirname, "dist", "firefox");
|
|
const SRC = path.join(__dirname, "src");
|
|
|
|
function ensureDir(dir) {
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
}
|
|
|
|
async function build() {
|
|
console.log("Building AutistMask extension...");
|
|
|
|
// compile tailwind CSS
|
|
console.log("Compiling Tailwind CSS...");
|
|
const tailwindInput = path.join(SRC, "popup", "styles", "main.css");
|
|
const tailwindOutput = path.join(__dirname, "dist", "styles.css");
|
|
ensureDir(path.join(__dirname, "dist"));
|
|
execSync(
|
|
`npx @tailwindcss/cli -i ${tailwindInput} -o ${tailwindOutput} --minify`,
|
|
{ stdio: "inherit" },
|
|
);
|
|
|
|
for (const distDir of [DIST_CHROME, DIST_FIREFOX]) {
|
|
ensureDir(path.join(distDir, "src", "popup"));
|
|
ensureDir(path.join(distDir, "src", "background"));
|
|
ensureDir(path.join(distDir, "src", "content"));
|
|
|
|
// bundle popup JS with esbuild (inlines ethers, libsodium, etc.)
|
|
await esbuild.build({
|
|
entryPoints: [path.join(SRC, "popup", "index.js")],
|
|
bundle: true,
|
|
format: "iife",
|
|
outfile: path.join(distDir, "src", "popup", "index.js"),
|
|
platform: "browser",
|
|
target: ["chrome110", "firefox110"],
|
|
minify: true,
|
|
});
|
|
|
|
// bundle background script
|
|
await esbuild.build({
|
|
entryPoints: [path.join(SRC, "background", "index.js")],
|
|
bundle: true,
|
|
format: "iife",
|
|
outfile: path.join(distDir, "src", "background", "index.js"),
|
|
platform: "browser",
|
|
target: ["chrome110", "firefox110"],
|
|
minify: true,
|
|
});
|
|
|
|
// bundle content script
|
|
await esbuild.build({
|
|
entryPoints: [path.join(SRC, "content", "index.js")],
|
|
bundle: true,
|
|
format: "iife",
|
|
outfile: path.join(distDir, "src", "content", "index.js"),
|
|
platform: "browser",
|
|
target: ["chrome110", "firefox110"],
|
|
minify: true,
|
|
});
|
|
|
|
// copy popup HTML
|
|
fs.copyFileSync(
|
|
path.join(SRC, "popup", "index.html"),
|
|
path.join(distDir, "src", "popup", "index.html"),
|
|
);
|
|
|
|
// place compiled CSS next to popup HTML
|
|
fs.copyFileSync(
|
|
tailwindOutput,
|
|
path.join(distDir, "src", "popup", "styles.css"),
|
|
);
|
|
}
|
|
|
|
// copy manifests
|
|
fs.copyFileSync(
|
|
path.join(__dirname, "manifest", "chrome.json"),
|
|
path.join(DIST_CHROME, "manifest.json"),
|
|
);
|
|
fs.copyFileSync(
|
|
path.join(__dirname, "manifest", "firefox.json"),
|
|
path.join(DIST_FIREFOX, "manifest.json"),
|
|
);
|
|
|
|
console.log("Build complete: dist/chrome/ and dist/firefox/");
|
|
}
|
|
|
|
build();
|