-
Notifications
You must be signed in to change notification settings - Fork 177
/
vite.config.mts
52 lines (48 loc) · 1.12 KB
/
vite.config.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { resolve } from 'path';
import { defineConfig } from 'vite';
import { name } from './package.json';
import dts from "vite-plugin-dts";
import stripComments from "vite-plugin-strip-comments";
const getPackageName = () => {
return (name.includes('@') ? name.split('/')[1] : name).replace('.', '-');
};
const NAME = 'BSN';
const mainFile = {
es: `${getPackageName()}.mjs`,
cjs: `${getPackageName()}.cjs`,
iife: `${getPackageName()}.js`,
};
export default defineConfig({
base: './',
resolve: {
alias: {
"~": resolve(__dirname, "src"),
},
},
esbuild: {
legalComments: 'none',
},
plugins: [
dts({
outDir: 'dist',
copyDtsFiles: true,
rollupTypes: true,
}),
stripComments({ type: 'none' }),
],
build: {
minify: 'esbuild',
target: 'ESNext',
outDir: 'dist',
emptyOutDir: true,
lib: {
entry: [
resolve(__dirname, 'src/index.ts'), // main file
],
name: NAME,
formats: ['es', 'cjs', 'iife'],
fileName: (format) => mainFile[format]
},
sourcemap: true,
},
});