Files
Slop-detect/scripts/build.mjs
T
2026-09-02 20:38:45 +02:00

41 lines
1.2 KiB
JavaScript

import { cp, mkdir } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { build } from 'esbuild';
const root = new URL('../', import.meta.url);
const outdir = new URL('../dist/', import.meta.url);
const rootPath = fileURLToPath(root);
const outdirPath = fileURLToPath(outdir);
await mkdir(outdir, { recursive: true });
await cp(new URL('../public/', import.meta.url), outdir, { recursive: true });
await cp(
new URL('../node_modules/@contentauth/c2pa-web/dist/resources/c2pa_bg.wasm', import.meta.url),
new URL('../dist/c2pa_bg.wasm', import.meta.url)
);
await cp(
new URL('../node_modules/@contentauth/c2pa-web/dist/c2pa_worker.js', import.meta.url),
new URL('../dist/c2pa_worker.js', import.meta.url)
);
await build({
absWorkingDir: rootPath,
entryPoints: {
background: 'src/background/index.ts',
content: 'src/content/index.ts',
popup: 'src/popup/index.tsx',
options: 'src/options/index.tsx'
},
outdir: outdirPath,
bundle: true,
format: 'iife',
platform: 'browser',
target: ['firefox128'],
jsx: 'automatic',
jsxImportSource: 'preact',
sourcemap: true,
minify: true,
legalComments: 'eof',
logLevel: 'info'
});