-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
42 lines (39 loc) · 1.13 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { type Plugin, defineConfig } from "vite";
import { globSync } from "tinyglobby";
const entryPoints = globSync(["**/*.html", "!dist", "!node_modules"]);
const head = async (): Promise<Plugin> => {
return {
name: "vite-plugin-head",
transformIndexHtml: {
order: "pre",
async handler(_, ctx) {
const preview =
ctx.originalUrl == "/" ? "/preview/blue.png" : "/preview.png";
return [
// <meta name="og:image" content="/preview/blue.png">
{
tag: "meta",
attrs: { name: "og:image", content: preview },
injectTo: "head",
},
// <link rel="icon" href="/icon.png" type="image/png">
{
tag: "link",
attrs: { rel: "icon", href: "/icon.png", type: "image/png" },
injectTo: "head",
},
];
},
},
};
};
// https://vitejs.dev/config/
export default defineConfig({
appType: "mpa" /* disable the SPA 404 fallback in dev mode. */,
plugins: [head()],
build: {
rollupOptions: {
input: Object.fromEntries(entryPoints.map((h) => [h, h])),
},
},
});