README / scripts /build.mjs
compute1's picture
Upload scripts/build.mjs with huggingface_hub
ecd4a46 verified
Raw History Blame Contribute Delete
941 Bytes
// Full card build:
// 1. client build (CSS chunk for the static card)
// 2. SSR build of the static entry (markup)
// 3. render-card: self-contained static org card (dist/index.html)
// 4. interactive React build for the Space (app/)
//
// npm install && node scripts/build.mjs
//
// Publish:
// - dist/index.html -> index.html (org card, static, no scripts)
// - app/ -> app/ (Space app, interactive React)
import { execSync } from 'node:child_process'
import { copyFileSync } from 'node:fs'
execSync('npx vite build', { stdio: 'inherit' })
execSync('npx vite build --ssr src/App.jsx --outDir .ssr --emptyOutDir', {
stdio: 'inherit',
})
execSync('node scripts/render-card.mjs', { stdio: 'inherit' })
execSync('npx vite build --config vite.app.config.js', { stdio: 'inherit' })
copyFileSync('app/app.html', 'app/index.html')
console.log('done: dist/index.html (static card) and app/ (interactive) ready')