-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvite.config.mts
90 lines (88 loc) · 2.34 KB
/
vite.config.mts
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
/// <reference types="vitest/config" />
import { defineConfig } from 'vite';
import path from 'node:path';
import react from '@vitejs/plugin-react';
import dts from 'vite-plugin-dts';
import autoExternal from 'rollup-plugin-auto-external';
import { visualizer } from 'rollup-plugin-visualizer';
import del from 'rollup-plugin-delete';
import { viteRequire } from 'vite-require';
const commonPlugins = [
viteRequire(),
react({
babel: {
plugins: [
'babel-plugin-styled-components',
'@prisma-capacity/babel-plugin-react-display-name',
],
},
}),
];
const isStorybook = process.env.STORYBOOK === 'true';
export default defineConfig({
assetsInclude: ['**/*.md'],
plugins: isStorybook
? commonPlugins
: [
autoExternal(),
...commonPlugins,
dts({
insertTypesEntry: true,
tsconfigPath: 'tsconfig.build.json',
}),
visualizer({
filename: 'stats/stat.html',
template: 'sunburst',
}),
del({
targets: ['build/tokens.css.d.ts'],
hook: 'closeBundle',
}),
],
build: {
outDir: 'build',
lib: {
entry: [
path.resolve(__dirname, 'src/index.ts'),
path.resolve(__dirname, 'src/tokens/tokens.css'),
path.resolve(__dirname, 'src/locales/en-US.ts'),
path.resolve(__dirname, 'src/locales/cs-CZ.ts'),
path.resolve(__dirname, 'src/locales/es-ES.ts'),
path.resolve(__dirname, 'src/locales/pt-BR.ts'),
path.resolve(__dirname, 'src/locales/ja-JP.ts'),
],
fileName: (format, name) => `${name}.${format === 'cjs' ? 'cjs' : 'mjs'}`,
formats: ['es', 'cjs'],
},
cssCodeSplit: true,
rollupOptions: {
external: [
'react/jsx-runtime',
'react-select/async',
'react-select/creatable',
'react-select/async-creatable',
],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'styled-components': 'styled',
},
interop: 'compat',
},
},
minify: true,
},
test: {
globals: true,
dir: './src',
setupFiles: './vitest-setup.ts',
include: ['**/*.test.(ts|tsx)'],
environment: 'happy-dom',
coverage: {
reporter: ['lcov'],
all: false,
reportsDirectory: './coverage/unit',
},
},
});