-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
38 lines (33 loc) · 1.08 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
import { defineConfig } from "vite";
import { resolve } from "node:path";
import dts from "vite-plugin-dts";
const isServer = process.env.BUILD_TARGET === "server";
export default defineConfig({
build: {
// We want to leave the minification to the users, so we don't minify
minify: false,
// We want to generate a manifest for the client, but not for the server
ssrManifest: !isServer,
ssr: isServer,
// We want to change the output dir and content based on the build target
outDir: isServer ? "dist/server" : "dist/client",
lib: {
entry: {
...(!isServer && { index: resolve(__dirname, "src/entry-client.ts") }),
...(isServer && { server: resolve(__dirname, "src/entry-server.ts") }),
},
// As of 2024, basically only "es" matters
formats: ["es"], // "cjs", "umd", "iife" ],
},
rollupOptions: {
external: ["ofetch"],
...(isServer && { input: "src/entry-server.ts" }),
},
},
plugins: [
// We include types to ease the use of the library
dts({
insertTypesEntry: true,
}),
],
});