-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
59 lines (58 loc) · 1.59 KB
/
Copy pathvite.config.ts
File metadata and controls
59 lines (58 loc) · 1.59 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/// <reference types="vitest" />
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import { visualizer } from "rollup-plugin-visualizer";
import { resolve } from "path";
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "calendar-simple", // Replace with your library name
formats: ["cjs", "es", "iife"],
fileName: (format) => {
const ext = format === "iife" ? "iife.js" : `${format}.js`;
return `index.${ext}`;
},
},
rollupOptions: {
// Externalize dependencies that shouldn't be bundled
external: ["react", "react-dom"],
output: {
// Provide global variables for IIFE/UMD builds
exports: "named",
globals: {
react: "React",
"react-dom": "ReactDOM",
},
extend: true,
},
},
sourcemap: true,
emptyOutDir: true, // Equivalent to tsup's clean: true
target: "es2020",
minify: "esbuild", // or 'terser'
chunkSizeWarningLimit: 2000,
},
test: {
globals: true,
environment: "jsdom",
setupFiles: "./src/setupTests.ts",
},
plugins: [
// Generates .d.ts files (equivalent to tsup's dts: true)
process.env.npm_lifecycle_event !== "build-storybook" &&
!process.env.STORYBOOK &&
dts({
include: ["src"],
exclude: ["node_modules", "dist"],
rollupTypes: false,
}),
process.env.ANALYZE &&
visualizer({
filename: "dist/stats.html",
open: true,
gzipSize: true,
brotliSize: true,
}),
],
});