-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathvite.config.ts
More file actions
96 lines (94 loc) · 2.76 KB
/
Copy pathvite.config.ts
File metadata and controls
96 lines (94 loc) · 2.76 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/// <reference types="vitest/config" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import svgrPlugin from 'vite-plugin-svgr';
import checker from 'vite-plugin-checker';
import { resolve } from 'path';
import external from 'rollup-plugin-peer-deps-external';
import dts from 'vite-plugin-dts';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import tailwindcss from '@tailwindcss/vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
export default defineConfig(({ mode }) =>
mode === 'library'
? {
plugins: [
tailwindcss(),
svgrPlugin(),
cssInjectedByJsPlugin(),
react(),
dts({
// vite-plugin-dts 5 (unplugin-dts): entryRoot + rootDir keep
// declarations flat at dist/ (TS 6 otherwise roots them at the
// project dir, emitting dist/src/** with no usable types entry)
include: ['src/**/*'],
entryRoot: 'src',
compilerOptions: { rootDir: 'src' }
}),
checker({
typescript: true
}),
viteStaticCopy({
targets: [
{
// static-copy v4: globs match files only ('stories/*' drops the
// assets subdirectory) and matches keep their full path under
// dest — so dest must be '' to land at dist/stories/**
src: 'stories/**/*',
dest: ''
},
]
})
],
resolve: {
// Vite 8 resolves tsconfig "paths" natively (replaces the
// vite-tsconfig-paths plugin); covers the '@/*' -> './src/*' alias
tsconfigPaths: true
},
build: {
minify: false,
sourcemap: true,
copyPublicDir: false,
lib: {
entry: resolve('src', 'index.ts'),
// ESM-only — no UMD/CJS build
formats: ['es'],
fileName: 'index'
},
rollupOptions: {
plugins: [
external({
includeDependencies: true
})
],
checks: {
// Rolldown profiling note, not a defect: svgr/checker/dts are
// JS plugins doing necessary work (SVG compile, tsc, d.ts emit)
pluginTimings: false
}
}
}
}
: {
plugins: [
svgrPlugin(),
react(),
checker({
typescript: true
})
],
resolve: {
tsconfigPaths: true
},
test: {
globals: true,
environment: 'jsdom',
exclude: ['node_modules', 'dist'],
coverage: {
// vitest 4 removed coverage.all (whole-project reporting);
// restore it by including all source files explicitly
include: ['src/**']
}
}
}
);