~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/pds.js

An atproto PDS in JavaScript, for Cloudflare Workers and Node

0
0
main
41 lines · 1.4 KB Raw History
import { fileURLToPath } from 'node:url';
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { viteSingleFile } from 'vite-plugin-singlefile';

// One document out, for the reason git-ui builds one: the site record names
// each file by path and the page HTML caches for minutes, so a build split
// across hashed assets would leave a visitor holding old HTML asking for a
// script the record no longer names. The deploy writes a second file,
// client-metadata.json, which the OAuth server reads and the page never does.

// Where `npm run dev` sends the one route the account's own site answers: the
// DID the hostname publishes, which prefills the sign-in field. Every other
// request the page makes is a cross-origin call to whichever PDS the visitor
// signed in to.
const PDS_URL = process.env.PDS_URL || 'http://localhost:2471';

export default defineConfig({
  plugins: [react(), tailwindcss(), viteSingleFile()],
  server: {
    proxy: {
      '/.well-known': PDS_URL,
    },
  },
  resolve: {
    alias: [
      {
        find: /^#\/(.*)/,
        replacement: `${fileURLToPath(new URL('./src', import.meta.url))}/$1`,
      },
    ],
  },
  build: {
    target: 'es2022',
    assetsInlineLimit: 100000000,
    chunkSizeWarningLimit: 4096,
    cssCodeSplit: false,
    reportCompressedSize: false,
  },
});