-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
47 lines (41 loc) · 1.11 KB
/
vite.config.js
File metadata and controls
47 lines (41 loc) · 1.11 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
import { defineConfig } from 'vite';
import path from 'path';
import fs from 'fs';
// Helper function to get all index.tsx files in the components directory
function getComponentEntries(dir) {
const entries = {};
const componentDirs = fs.readdirSync(dir);
componentDirs.forEach((componentDir) => {
const fullPath = path.join(dir, componentDir, 'index.tsx');
if (fs.existsSync(fullPath)) {
const entryName = path.join('components', componentDir, 'index');
entries[entryName] = fullPath;
}
});
return entries;
}
const componentEntries = getComponentEntries(path.resolve(__dirname, 'src/components'));
export default defineConfig({
build: {
rollupOptions: {
input: {
index: path.resolve(__dirname, 'src/index.tsx'),
...componentEntries
},
output: [
{
format: 'cjs',
dir: 'dist/cjs',
entryFileNames: '[name].js'
},
{
format: 'es',
dir: 'dist/es',
entryFileNames: '[name].js'
}
],
// 其他 rollup 配置
external: ['yselement'],
},
},
});