-
Notifications
You must be signed in to change notification settings - Fork 177
/
vite.config.components.mts
37 lines (34 loc) · 1.06 KB
/
vite.config.components.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
import { resolve } from 'path';
import { defineConfig } from 'vite';
import dts from "vite-plugin-dts";
import stripComments from "vite-plugin-strip-comments";
const components = ['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast', 'tooltip'];
const componentFile = (entry: string, format: string) => {
const ext = format === 'iife' ? 'js' : format === 'es' ? 'mjs' : format;
return `${entry}.${ext}`
};
export default defineConfig({
base: './',
esbuild: {
legalComments: 'none',
},
plugins: [
dts({
outDir: 'dist/components',
copyDtsFiles: true,
rollupTypes: true,
}),
stripComments({ type: 'none' }),
],
build: {
target: 'ESNext',
minify: 'esbuild',
outDir: 'dist/components',
lib: {
entry: components.map((component) => resolve(__dirname, `src/components/${component}.ts`)),
formats: ['es', 'cjs'],
fileName: (format, entry) => componentFile(entry, format),
},
sourcemap: true,
},
});