Download scripts/build.js from lewtun/cowrite: direct link, hf CLI and curl.
- Browser
- Download file 992 Bytes
-
https://huggingface.co/spaces/lewtun/cowrite/resolve/main/scripts/build.js
- Command line
-
hf download hf://spaces/lewtun/cowrite/scripts/build.js
-
curl -L -o build.js https://huggingface.co/spaces/lewtun/cowrite/resolve/main/scripts/build.js
992 Bytes
| import esbuild from 'esbuild' | |
| import fs from 'node:fs' | |
| import path from 'node:path' | |
| import { fileURLToPath } from 'node:url' | |
| const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..') | |
| const pub = path.join(root, 'public') | |
| fs.mkdirSync(pub, { recursive: true }) | |
| // version stamp: the server rejects websocket clients from other builds so a | |
| // stale tab can never silently corrupt a doc with its old state | |
| const buildId = String(Date.now()) | |
| await esbuild.build({ | |
| entryPoints: [path.join(root, 'client/src/doc.js'), path.join(root, 'client/src/home.js')], | |
| bundle: true, | |
| minify: true, | |
| format: 'iife', | |
| outdir: pub, | |
| define: { 'process.env.NODE_ENV': '"production"', __BUILD_ID__: JSON.stringify(buildId) }, | |
| logLevel: 'info', | |
| }) | |
| for (const f of ['doc.html', 'index.html', 'app.css']) { | |
| fs.copyFileSync(path.join(root, 'client', f), path.join(pub, f)) | |
| } | |
| fs.writeFileSync(path.join(pub, 'build-id'), buildId) | |
| console.log('build done ->', pub, 'build-id', buildId) | |