Add resolver, server, PDF rendering and web app
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
6a7fcdc4b8
commit
bdfdf581f3
59 files changed
+4088
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { build } from 'esbuild';
|
||||
import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = fileURLToPath(new URL('..', import.meta.url));
|
||||
const out = `${root}dist/web`;
|
||||
await mkdir(out, { recursive: true });
|
||||
|
||||
await build({
|
||||
entryPoints: [`${root}src/web/main.tsx`],
|
||||
outfile: `${out}/app.js`,
|
||||
bundle: true,
|
||||
format: 'esm',
|
||||
sourcemap: true,
|
||||
jsx: 'automatic',
|
||||
jsxImportSource: 'preact',
|
||||
target: 'es2022',
|
||||
minify: false,
|
||||
logLevel: 'info',
|
||||
});
|
||||
|
||||
// zxing-wasm ships a default locateFile pointing at jsDelivr. scanner.ts always overrides it, so it is
|
||||
// dead code, but neutralise the URL anyway so the bundle contains no CDN address at all.
|
||||
const appJs = await readFile(`${out}/app.js`, 'utf8');
|
||||
await writeFile(`${out}/app.js`, appJs.replaceAll('https://fastly.jsdelivr.net/npm/', '/local-only/'));
|
||||
|
||||
await copyFile(`${root}src/web/index.html`, `${out}/index.html`);
|
||||
await copyFile(`${root}src/web/styles.css`, `${out}/styles.css`);
|
||||
// The zxing reader wasm is served from our own server at /zxing_reader.wasm (see scanner.ts).
|
||||
await copyFile(`${root}node_modules/zxing-wasm/dist/reader/zxing_reader.wasm`, `${out}/zxing_reader.wasm`);
|
||||
console.log('Built dist/web');
|
||||
Reference in new issue
Block a user