59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
// @ts-check
|
|
import { defineConfig, fontProviders } from "astro/config";
|
|
import mdx from "@astrojs/mdx";
|
|
import sitemap from "@astrojs/sitemap";
|
|
|
|
import react from "@astrojs/react";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import { attachDiceSyncServer } from "./server/dice-sync.mjs";
|
|
// Admin API runs as a standalone Netlify Function (see netlify/functions/admin.mts)
|
|
|
|
const attachedServers = new WeakSet();
|
|
const classroomSync = () => ({
|
|
name: "classroom-dice-sync",
|
|
configureServer(server) {
|
|
if (server.httpServer && !attachedServers.has(server.httpServer)) {
|
|
attachDiceSyncServer(server.httpServer);
|
|
attachedServers.add(server.httpServer);
|
|
}
|
|
},
|
|
configurePreviewServer(server) {
|
|
if (server.httpServer && !attachedServers.has(server.httpServer)) {
|
|
attachDiceSyncServer(server.httpServer);
|
|
attachedServers.add(server.httpServer);
|
|
}
|
|
},
|
|
});
|
|
|
|
// https://astro.build/config
|
|
export default defineConfig({
|
|
site: "https://interactives.neeldhara.com",
|
|
integrations: [mdx(), sitemap(), react()],
|
|
output: "static",
|
|
|
|
fonts: [
|
|
{
|
|
provider: fontProviders.fontsource(),
|
|
name: "Imprima",
|
|
cssVariable: "--font-imprima",
|
|
},
|
|
],
|
|
|
|
vite: {
|
|
plugins: [tailwindcss(), classroomSync()],
|
|
build: {
|
|
target: "es2022",
|
|
minify: "esbuild",
|
|
// Sanitize chunk filenames — Netlify esbuild chokes on ! and ~ in names
|
|
rollupOptions: {
|
|
output: {
|
|
sanitizeFileName: (name) => name.replace(/[^\w./-]/g, "_"),
|
|
},
|
|
},
|
|
},
|
|
esbuild: {
|
|
target: "es2022",
|
|
charset: "utf8",
|
|
},
|
|
},
|
|
});
|