import { defineConfig } from "vite"; import dts from "vite-plugin-dts"; export default defineConfig({ root: __dirname, cacheDir: "../../../../node_modules/.vite/packages/pwa", plugins: [ dts({ entryRoot: "src", tsconfigPath: "./tsconfig.lib.json", insertTypesEntry: true, }), ], build: { outDir: "./dist", emptyOutDir: true, reportCompressedSize: true, sourcemap: true, lib: { entry: { index: "src/index.ts", "errors/errors": "src/errors/errors.ts", "schemas/schemas": "src/schemas/schemas.ts", "observability/observability": "src/observability/observability.ts", "service-worker/service-worker": "src/service-worker/service-worker.ts", "update-controller/update-controller": "src/update-controller/update-controller.ts", "sync-queue/sync-queue": "src/sync-queue/sync-queue.ts", "sync-queue/memory-store": "src/sync-queue/memory-store.ts", "sync-queue/local-storage-store": "src/sync-queue/local-storage-store.ts", "sync-queue/indexeddb-store": "src/sync-queue/indexeddb-store.ts", "sync-queue/background-sync": "src/sync-queue/background-sync.ts", "sync-queue/version-migration": "src/sync-queue/version-migration.ts", "push-notifications/push-notifications": "src/push-notifications/push-notifications.ts", "push-notifications/vapid": "src/push-notifications/vapid.ts", "install-prompt/install-prompt": "src/install-prompt/install-prompt.ts", "caching-strategies/caching-strategies": "src/caching-strategies/caching-strategies.ts", "caching-strategies/router": "src/caching-strategies/router.ts", "manifest/manifest": "src/manifest/manifest.ts", }, formats: ["es"], }, rollupOptions: { treeshake: true, output: { preserveModules: true, preserveModulesRoot: "src", entryFileNames: "[name].js", }, external: [ "@suaveplan/error", "@suaveplan/opentelemetry", "@suaveplan/types", "@opentelemetry/api", "tslib", "zod", /^node:/, ], }, }, });