-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
71 lines (68 loc) · 1.75 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/// <reference types="vitest" />
/// <reference types="vite/client" />
import { resolve } from "node:path";
import react from "@vitejs/plugin-react";
import { PluginPure } from "rollup-plugin-pure";
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import { viteStaticCopy } from "vite-plugin-static-copy";
import tsConfigPaths from "vite-tsconfig-paths";
import * as packageJson from "./package.json";
// https://vitejs.dev/config/
// @ts-ignore
export default defineConfig(({ mode }) => ({
define: {
"process.env.NODE_ENV": JSON.stringify(mode),
},
plugins: [
react(),
tsConfigPaths(),
viteStaticCopy({
targets: [
{
src: "src/tailwind.plugin.ts",
dest: "",
},
],
}),
dts({
include: ["src/components/", "src/index.ts"],
exclude: ["**/*.test.tsx", "**/*.stories.tsx"],
}),
],
build: {
lib: {
entry: resolve("src", "index.ts"),
name: "SwitchUI",
formats: ["es"],
fileName: (format) => `ui.${format}.js`,
},
rollupOptions: {
plugins: [
PluginPure({
sourcemap: true,
functions: [
"React.createElement",
"React.forwardRef", // Used for heroicons
"forwardRefWithAs",
"cva",
],
}),
],
external: [
...Object.keys(packageJson.peerDependencies),
...Object.keys(packageJson.dependencies),
"react-select/async",
"react/jsx-runtime",
],
},
sourcemap: true,
},
test: {
environment: "jsdom",
setupFiles: ["./src/tests/setup.ts"],
testMatch: ["./tests/**/*.test.tsx"],
globals: true,
},
}));