# vite.config.ts

> 57 lines of code and 2 definitions.

Tree: Site tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/tree#file-vite-config-ts
Source text: https://banes-lab.com/assets/sources/source.bb906c4502bb56cb20c697757c462dba7763fc682edd14adc43cbafa33d7ee94.generated.txt

## Definitions

- `COMPRESSION_THRESHOLD` (lexical_declaration, line 19)
- `CSP_NONCE_PLACEHOLDER` (lexical_declaration, line 20)

## Source

```typescript
import { DEV_PORT } from "@project/scripts/web.scripts/server.constants.ts";
import { absolutePath } from "@ssot/paths";
import { compression } from "vite-plugin-compression2";
import { defineConfig } from "vite";
import { devCertificate } from "@project/scripts/web.scripts/build-dev-certificate.ts";
import { diagramPlugin } from "@project/scripts/web.scripts/build-diagrams.ts";
import { iconsPlugin } from "@project/scripts/web.scripts/build-icons.ts";
import { deriveAnatomy } from "@project/scripts/web.scripts/build-anatomy.ts";
import { chaptersPlugin } from "@project/scripts/web.scripts/build-chapters.ts";
import { coordinationPlugin } from "@project/scripts/web.scripts/build-coordination.ts";
import { join } from "node:path";
import { learningPlugin } from "@project/scripts/web.scripts/build-learning-map.ts";
import { metricsPlugin } from "@project/scripts/web.scripts/build-metrics.ts";
import { ontologyPlugin } from "@project/scripts/web.scripts/build-ontology.ts";
import { prerenderPlugin } from "@project/scripts/web.scripts/build-prerender.ts";
import { prunePlugin } from "@project/scripts/web.scripts/build-prune.ts";
import { tabsPlugin } from "@project/scripts/web.scripts/build-tabs.ts";

const COMPRESSION_THRESHOLD = 256;
const CSP_NONCE_PLACEHOLDER = "__CSP_NONCE__";

export default defineConfig(async ({ mode }) => {
    await deriveAnatomy();
    return {
        base: "/",
        build: {
            assetsInlineLimit: 0,
            emptyOutDir: true,
            outDir: absolutePath("builds.web"),
            rollupOptions: {
                input: { main: join(absolutePath("app.member"), "index.html") },
                output: {
                    assetFileNames: "assets/[hash][extname]",
                    chunkFileNames: "assets/[hash].js",
                    entryFileNames: "assets/[hash].js",
                },
            },
            target: "esnext",
        },
        html: { cspNonce: CSP_NONCE_PLACEHOLDER },
        plugins: [
            ontologyPlugin(),
            metricsPlugin(),
            iconsPlugin(),
            diagramPlugin(),
            prerenderPlugin(),
            learningPlugin(),
            tabsPlugin(),
            prunePlugin(),
            chaptersPlugin(),
            coordinationPlugin(),
            mode === "production" &&
                compression({ algorithms: ["brotliCompress", "gzip"], threshold: COMPRESSION_THRESHOLD }),
        ],
        publicDir: absolutePath("app.public"),
        root: absolutePath("app.member"),
        server: { https: await devCertificate(), port: DEV_PORT, strictPort: true },
    };
});
```
