-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
83 lines (82 loc) · 2.21 KB
/
vite.config.ts
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
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react-swc';
// import vitePluginImp from 'vite-plugin-imp';
import dts from 'vite-plugin-dts';
// https://vitejs.dev/config/
export default defineConfig({
base: './',
server: {
port: 3000,
host: '0.0.0.0'
},
plugins: [
react(),
// vitePluginImp({
// libList: [
// {
// libName: 'lodash',
// libDirectory: '',
// camel2DashComponentName: false
// },
// {
// libName: '@arco-design/web-react',
// libDirectory: 'es',
// camel2DashComponentName: false,
// style(name) {
// return `@arco-design/web-react/es/${name}/style/index.js`;
// }
// }
// ]
// }),
dts({
rollupTypes: true,
insertTypesEntry: true,
copyDtsFiles: true
})
],
test: {
globals: true,
setupFiles: './vitest-setup.ts',
environment: 'jsdom',
include: ['src/themes/*.test.{ts,tsx}'],
exclude: ['**/node_modules/**', '**/dist/**'],
coverage: {
include: ['src/themes/*.{ts,tsx}'],
exclude: ['**/*.test.{ts,tsx}', '**/node_modules/**', '**/dist/**', '**/*.d.ts*']
}
},
css: {
modules: {
// generateScopedName: '[name]__[local]'
generateScopedName: '[local]'
}
},
build: {
minify: 'terser',
lib: {
entry: 'src/index.ts',
name: 'ReactThemes',
formats: ['cjs', 'es', 'umd'],
fileName: (format) => `index.${format === 'es' ? 'esm' : format === 'cjs' ? 'cmd' : format}.js`
},
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external: ['react', 'react-dom', 'react/jsx-runtime', 'classnames', 'lomind', 'lomind-react'],
output: {
// 为各种格式提供全局变量名
globals: {
react: 'react',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'react/jsx-runtime'
},
// 这里定义了静态资源构建输出的命名
assetFileNames: (assetInfo) => {
if (assetInfo.name === 'style.css') {
return 'index.css';
}
return assetInfo.name;
}
}
}
}
});