-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
75 lines (71 loc) · 2.26 KB
/
vite.config.ts
File metadata and controls
75 lines (71 loc) · 2.26 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
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react-swc';
import path from 'path';
import { defineConfig, type UserConfig } from 'vite';
const aliases = {
'@': path.resolve(__dirname, './src'),
'@assets': path.resolve(__dirname, './src/assets'),
'@atoms': path.resolve(__dirname, './src/components/atoms'),
'@molecules': path.resolve(__dirname, './src/components/molecules'),
'@organisms': path.resolve(__dirname, './src/components/organisms'),
'@hooks': path.resolve(__dirname, './src/hooks'),
'@styles': path.resolve(__dirname, './src/styles'),
'@utils': path.resolve(__dirname, './src/utils')
};
type TestConfig = {
globals: boolean;
environment: 'jsdom';
setupFiles: string[];
css: boolean;
alias: typeof aliases;
coverage: {
provider: 'v8';
reporter: string[];
include: string[];
exclude: string[];
};
};
const config = {
base: './',
plugins: [react(), tailwindcss()],
resolve: {
alias: aliases
},
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'StackAndFlowDesignSystem',
formats: ['es', 'cjs'],
fileName: (format: string) => `index.${format === 'es' ? 'js' : 'cjs'}`
},
rollupOptions: {
external: ['react', 'react-dom', 'react/jsx-runtime', 'lucide-react', /^lucide-react\/.*/],
output: {
assetFileNames: (assetInfo: { name?: string }) =>
assetInfo.name?.endsWith('.css') ? 'design-system.css' : 'assets/[name]-[hash][extname]',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'ReactJSXRuntime',
'lucide-react': 'LucideReact'
}
}
},
sourcemap: true,
emptyOutDir: true
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./tests/setup.ts'],
css: false,
alias: aliases,
coverage: {
provider: 'v8',
reporter: ['text', 'lcov'],
include: ['src/components/**/*.ts', 'src/components/**/*.tsx'],
exclude: ['src/components/**/*.stories.tsx', 'src/components/**/*.test.*', 'src/components/**/index.ts']
}
}
} satisfies UserConfig & { test: TestConfig };
export default defineConfig(config);