Single-binary self-hosted website analytics on Rust axum: collector API, dashboards, world map, and PDF reports.
analyticsaxumdockerrustself-hostedsqliteviteweb-analytics
1import { resolve } from "path";
2import { defineConfig } from "vite";
3
4// Vite output goes to ../dist; Rust serves it at /static/.
5// Manifest is read at runtime so templates resolve hashed asset names.
6// Four entry points mirror the original Django split: base (shared shell),
7// pages (marketing static pages), properties (dashboard charts/map), and
8// collector (the public embed script).
9
10export default defineConfig({
11 base: "/static/",
12 build: {
13 outDir: resolve(__dirname, "../dist"),
14 emptyOutDir: true,
15 manifest: true,
16 rollupOptions: {
17 input: {
18 base: resolve(__dirname, "static_src/base/index.js"),
19 pages: resolve(__dirname, "static_src/pages/index.js"),
20 properties: resolve(__dirname, "static_src/properties/index.js"),
21 collector: resolve(__dirname, "static_src/collector/index.js"),
22 },
23 output: {
24 // Hashed asset filenames so we can cache them aggressively.
25 entryFileNames: "assets/[name]-[hash].js",
26 chunkFileNames: "assets/[name]-[hash].js",
27 assetFileNames: (assetInfo) => {
28 if (/\.(png|jpg|gif|svg|webp)$/.test(assetInfo.name || "")) {
29 return "images/[name]-[hash][extname]";
30 }
31 return "assets/[name]-[hash][extname]";
32 },
33 },
34 },
35 },
36 css: {
37 preprocessorOptions: {
38 scss: {
39 quietDeps: true,
40 },
41 },
42 },
43});