repos
/ orchard main

orchard

mirror

Every site I host, in one repo, along with the Cloudflare Tunnel and Caddy that front them. It's all Go, Vite, and SQLite, and it runs on a desktop at home with nothing listening on an inbound port.

blogbuncaddycloudflare-tunneldockergogolanghomelabhtml-templatemonorepoself-hostedseosqlitestatic-sitetypstuptime-monitoringviteweb-analytics

1.4 KB · 42 lines · JavaScript Raw History
 1import { resolve } from "path";
 2import { defineConfig } from "vite";
 3
 4export default defineConfig({
 5  root: "static_src",
 6  base: "/static/",
 7  build: {
 8    outDir: resolve(__dirname, "../build/dist"),
 9    emptyOutDir: true,
10    manifest: true,
11    // Never inline a font. Vite base64s anything under 4KB into the stylesheet,
12    // which catches the smaller @fontsource subsets, and a data: URI is both
13    // blocked by this site's font-src CSP and re-downloaded with every CSS
14    // change instead of being cached for a year under its hashed name.
15    assetsInlineLimit: (filePath) =>
16      /\.(woff2?|eot|ttf|otf)$/.test(filePath) ? false : undefined,
17    rollupOptions: {
18      input: resolve(__dirname, "static_src/index.js"),
19      output: {
20        entryFileNames: "base-[hash].js",
21        assetFileNames: (assetInfo) => {
22          if (/\.(woff2?|eot|ttf|otf)$/.test(assetInfo.name)) {
23            // Hashed, since web/static.go stamps a year of immutable on every
24            // asset the manifest lists, and a font swap at an unhashed name
25            // could never reach a returning visitor.
26            return "fonts/[name]-[hash][extname]";
27          }
28          if (/\.css$/.test(assetInfo.name)) {
29            return "base-[hash].css";
30          }
31          return "assets/[name]-[hash][extname]";
32        },
33      },
34    },
35  },
36  css: {
37    preprocessorOptions: {
38      scss: { quietDeps: true },
39    },
40  },
41});