Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
71 lines (68 loc) · 2.28 KB
/
Copy pathvite.config.ts
File metadata and controls
71 lines (68 loc) · 2.28 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
/// <reference types="vitest/config" />
import { copyFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
const libRoot = resolve(dirname(fileURLToPath(import.meta.url)), 'lib');
// tokens.css/utilities.css/base.css ship as standalone subpath exports as well
// as folded into style.css, so they are copied verbatim into dist. Only dist/ is
// published, and base.css must stay out of style.css: it is an opt-in document
// layer, and cssCodeSplit: false would fold every CSS the entry graph touches.
const copyStandaloneCss = {
name: 'copy-standalone-css',
closeBundle() {
for (const [from, to] of [
['styles/base.css', 'base.css'],
['styles/tokens.css', 'tokens.css'],
['utilities.css', 'utilities.css'],
] as const) {
copyFileSync(resolve(libRoot, from), resolve(libRoot, '../dist', to));
}
},
};
export default defineConfig({
plugins: [
dts({
include: ['lib'],
exclude: ['**/*.test.tsx', '**/*.test.ts', '**/*.test.d.ts'],
tsconfigPath: './tsconfig.json',
}),
copyStandaloneCss,
],
build: {
lib: {
entry: { main: 'lib/main.ts', theme: 'lib/theme.ts' },
formats: ['es', 'cjs'],
cssFileName: 'style',
fileName: (format, name) => `${name}.${format}.js`,
},
rollupOptions: {
external: ['react', 'react-dom', 'react/jsx-runtime'],
},
cssCodeSplit: false,
},
test: {
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
exclude: ['e2e/**', 'node_modules/**', 'dist/**', 'demos/dist/**'],
// Coverage provider installed (@vitest/coverage-v8, version-matched to
// vitest) and enforced on every run. Thresholds sit at measured levels
// (measured 2026-09-28: 82.25/74.96/89.02/84.16) — raise, never lower.
coverage: {
provider: 'v8',
enabled: true,
// Gates the shipped library only. The demos app is guarded by
// e2e (demo-completeness + the axe crawl), so loading its pages here
// would dilute lib thresholds.
include: ['lib/**'],
reporter: ['text', 'lcov'],
thresholds: {
statements: 80,
branches: 74,
functions: 88,
lines: 84,
},
},
},
});