34 lines
872 B
JavaScript

import { copyFile, mkdir, rm } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { build } from "tsup";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const projectRoot = path.resolve(__dirname, "..");
const distDir = path.join(projectRoot, "dist");
await rm(distDir, { force: true, recursive: true });
await build({
clean: false,
dts: false,
entry: {
"content/index": path.join(projectRoot, "src/content/index.ts"),
"page/hook": path.join(projectRoot, "src/page/hook.ts")
},
format: ["iife"],
minify: false,
outDir: distDir,
platform: "browser",
silent: true,
splitting: false,
target: "es2022",
treeshake: false
});
await mkdir(distDir, { recursive: true });
await copyFile(
path.join(projectRoot, "src/manifest.json"),
path.join(distDir, "manifest.json")
);