-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.mts
More file actions
34 lines (32 loc) · 1.02 KB
/
vite.config.mts
File metadata and controls
34 lines (32 loc) · 1.02 KB
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
import { defineConfig } from "vite";
export default defineConfig(({ mode }) => {
if (mode === "lib") {
// Build for npm package (ESM/CJS)
return {
build: {
lib: {
entry: "src/index.ts",
fileName: (format) => `index.${format === "es" ? "mjs" : "cjs"}`,
formats: ["es", "cjs"],
},
emptyOutDir: false,
outDir: "dist",
minify: false,
},
};
}
// Default: Build for browser (IIFE), output to root for GitHub CDN
return {
build: {
lib: {
entry: "src/browser.ts",
name: "ReadTime",
fileName: () => "readtime.js",
formats: ["iife"],
},
emptyOutDir: false, // CRITICAL: Do not delete other files in root!
outDir: ".", // Output to project root
minify: false, // Un-minified as requested
},
};
});