build.mjs 632 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env zx
  2. /* eslint-disable no-undef */
  3. import 'zx/globals'
  4. import fs from 'fs'
  5. import path from 'path'
  6. // Build with [tsup](https://tsup.egoist.sh)
  7. await $`npx tsup`
  8. // Prepare package.json file
  9. const packageJson = fs.readFileSync('package.json', 'utf8')
  10. const glob = JSON.parse(packageJson)
  11. Object.assign(glob, {
  12. main: './index.js',
  13. module: './index.mjs',
  14. })
  15. fs.writeFileSync('dist/package.json', JSON.stringify(glob, null, 2))
  16. const dest = path.join(__dirname, '/../../../src/main/frontend/tldraw-logseq.js')
  17. if (fs.existsSync(dest)) fs.unlinkSync(dest)
  18. fs.linkSync(path.join(__dirname, '/dist/index.js'), dest)