2026-03-22 02:57:49 +08:00
|
|
|
import path from "node:path";
|
2026-06-29 10:47:30 +08:00
|
|
|
import { sentryVitePlugin } from "@sentry/vite-plugin";
|
2026-03-25 09:27:12 +08:00
|
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
import { defineConfig } from "vite";
|
2026-03-22 02:57:49 +08:00
|
|
|
|
2026-06-29 10:47:30 +08:00
|
|
|
// Source maps are emitted and uploaded to Sentry only when the build supplies
|
|
|
|
|
// SENTRY_AUTH_TOKEN (the published Docker image does; dev and the source-archive
|
|
|
|
|
// build do not). Debug IDs tie each build's bundle to its own maps, so upload
|
|
|
|
|
// works regardless of release. Maps are deleted after upload so they never ship.
|
|
|
|
|
const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN;
|
|
|
|
|
const sentryRelease = process.env.SENTRY_RELEASE;
|
|
|
|
|
|
2026-03-22 02:57:49 +08:00
|
|
|
export default defineConfig({
|
2026-06-29 10:47:30 +08:00
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
tailwindcss(),
|
|
|
|
|
// Must come after the other plugins so it sees the final bundle.
|
|
|
|
|
sentryVitePlugin({
|
|
|
|
|
org: "snapotter",
|
|
|
|
|
project: "node",
|
|
|
|
|
authToken: sentryAuthToken,
|
|
|
|
|
telemetry: false,
|
|
|
|
|
disable: !sentryAuthToken,
|
|
|
|
|
applicationKey: "snapotter-web",
|
|
|
|
|
// Don't inject the release into the bundle; the SDK reads it explicitly
|
|
|
|
|
// from VITE_SENTRY_RELEASE so there is a single source of truth.
|
|
|
|
|
release: { name: sentryRelease, inject: false },
|
|
|
|
|
sourcemaps: { filesToDeleteAfterUpload: ["./dist/**/*.map"] },
|
|
|
|
|
}),
|
|
|
|
|
],
|
2026-03-22 02:57:49 +08:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": path.resolve(__dirname, "./src"),
|
|
|
|
|
},
|
2026-03-22 03:03:07 +08:00
|
|
|
dedupe: ["react", "react-dom"],
|
2026-03-22 02:57:49 +08:00
|
|
|
},
|
|
|
|
|
server: {
|
2026-04-24 18:02:21 +08:00
|
|
|
host: true,
|
|
|
|
|
port: Number(process.env.PORT) || 1351,
|
2026-03-22 02:57:49 +08:00
|
|
|
proxy: {
|
2026-05-13 11:35:33 +08:00
|
|
|
"/api": {
|
|
|
|
|
target: process.env.VITE_API_URL || "http://localhost:13490",
|
|
|
|
|
timeout: 300_000,
|
|
|
|
|
proxyTimeout: 300_000,
|
|
|
|
|
},
|
2026-03-22 02:57:49 +08:00
|
|
|
},
|
|
|
|
|
},
|
2026-06-10 22:01:13 +08:00
|
|
|
// vite preview serves the production build for e2e runs; it needs the same
|
|
|
|
|
// /api proxy the dev server has (the app always calls relative /api).
|
|
|
|
|
preview: {
|
|
|
|
|
host: true,
|
|
|
|
|
port: Number(process.env.PORT) || 1351,
|
|
|
|
|
proxy: {
|
|
|
|
|
"/api": {
|
|
|
|
|
target: process.env.VITE_API_URL || "http://localhost:13490",
|
|
|
|
|
timeout: 300_000,
|
|
|
|
|
proxyTimeout: 300_000,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-15 18:13:23 +08:00
|
|
|
build: {
|
2026-06-29 10:47:30 +08:00
|
|
|
// Hidden source maps: generated for upload but not referenced from the
|
|
|
|
|
// shipped JS, so browsers never fetch them. Off entirely when not uploading.
|
|
|
|
|
sourcemap: sentryAuthToken ? "hidden" : false,
|
2026-04-15 18:13:23 +08:00
|
|
|
rollupOptions: {},
|
|
|
|
|
},
|
2026-03-22 02:57:49 +08:00
|
|
|
});
|