-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.lib.ts
48 lines (44 loc) · 1.05 KB
/
vite.config.lib.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
import path from 'path'
import { defineConfig, UserConfigExport } from 'vite'
import banner from 'vite-plugin-banner'
import compression from 'vite-plugin-compression'
import { bannerTemplate, camelCaseName, isProduction, shortName } from './env'
const config: UserConfigExport = defineConfig({
plugins: [
banner(bannerTemplate),
compression({
algorithm: 'brotliCompress',
ext: '.gz',
}),
],
build: {
outDir: 'dist',
emptyOutDir: true,
lib: {
entry: 'src/index.ts',
name: camelCaseName,
formats: ['es', 'cjs', 'umd', 'iife'],
fileName: format => `${shortName}.${format}.min.js`,
},
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
rollupOptions: {
output: {
banner: bannerTemplate,
},
},
sourcemap: isProduction ? false: 'inline',
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
extensions: ['.js', '.json', '.ts'],
}
})
export default config