# Debian build recipe for @benrbray/prosemirror-math.
#
# Upstream builds the library with vite (vite.config.lib.ts + vite-plugin-dts).
# Debian does not ship vite - the "vite" package is the Qt build tool - so the
# same pipeline is driven with rollup, which is what vite itself wraps:
#
#   upstream                                    here
#   ------------------------------------------  ----------------------------------------
#   vite build (lib entry lib/main.ts)          rollup + @rollup/plugin-typescript
#   vite-plugin-dts rollupTypes: true           tsc + rollup + rollup-plugin-dts
#   copy of public/ into dist/                  cp public/prosemirror-math.css
#
# Only lib/ is built.  src/ and index.html are the upstream demo website, which
# is not shipped in the binary package.

mkdir -p dist
rollup --config debian/build/rollup.config.mjs
rm -rf dist/rollup-tsbuild
tsc --project debian/build/tsconfig.json
rollup --config debian/build/rollup.dts.mjs
rm -rf dist/types
cp -p public/prosemirror-math.css dist/prosemirror-math.css
