-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
72 lines (71 loc) · 2.01 KB
/
Copy pathvite.config.ts
File metadata and controls
72 lines (71 loc) · 2.01 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
import { fileURLToPath } from 'node:url'
import path from 'node:path'
import { defineConfig } from 'vitest/config'
import { libInjectCss } from 'vite-plugin-lib-inject-css'
import dts from 'vite-plugin-dts'
import { globSync } from 'glob'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
react(),
libInjectCss(),
dts({
exclude: [
'./src/stories',
'./src/test',
'./src/components/**/*.test.tsx',
],
}),
],
resolve: {
alias: {
'@components': path.resolve(__dirname, './src/components'),
'@stories': path.resolve(__dirname, './src/stories'),
'@styles': path.resolve(__dirname, './src/styles'),
'@tps': path.resolve(__dirname, './src/types'),
},
},
build: {
lib: {
entry: path.resolve(__dirname, './src/index.ts'),
formats: ['es'],
},
emptyOutDir: true,
sourcemap: true,
rollupOptions: {
external: ['react', 'react-dom', 'react/jsx-runtime'],
input: Object.fromEntries(
globSync([
'./src/index.ts',
'./src/components/**/*.tsx',
'./src/styles/**/*.scss',
'./src/styles/tokens/modules/**/*.scss',
'./src/types/**/*.ts',
])
.filter(
(file) =>
(!/\.test\.tsx|\.test\.ts$/.test(file) &&
!/\/modules\/.*\.scss$/.test(file)) ||
/\/modules\/.*\.module\.scss$/.test(file)
)
.map((file) => {
const entryName = path.relative(
'src',
file.slice(0, file.length - path.extname(file).length)
)
const entryUrl = fileURLToPath(new URL(file, import.meta.url))
return [entryName, entryUrl]
})
),
output: {
entryFileNames: '[name].js',
assetFileNames: 'assets/[name][extname]',
globals: {
react: 'React',
'react-dom': 'React-dom',
'react/jsx-runtime': 'react/jsx-runtime',
},
},
},
},
})