forked from Sage/jsurl
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.mts
61 lines (60 loc) · 1.23 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
53
54
55
56
57
58
59
60
61
import {defineConfig} from 'vite'
import terser from '@rollup/plugin-terser'
import dts from 'vite-plugin-dts'
export default defineConfig({
// Keep the meta info
define: {
'import.meta.env': 'import.meta.env',
'import.meta.env.BASE_URL': 'import.meta.env.BASE_URL',
'import.meta.env.DEV': 'import.meta.env.DEV',
},
ssr: {
noExternal: true,
},
build: {
ssr: true,
minify: true,
sourcemap: true,
target: 'es2020',
lib: {
name: 'JSURL',
entry: ['./src'],
formats: ['es', 'umd'],
},
rollupOptions: {
// plugins: [],
},
},
plugins: [
dts({
exclude: ['/**/*.test.*'],
entryRoot: 'src',
include: ['src'],
}),
// we want to mangle the esm build too so we have to call terser ourselves
terser({
ecma: 2020,
compress: {
keep_infinity: true,
passes: 3,
unsafe: true,
unsafe_arrows: true,
unsafe_comps: true,
unsafe_Function: true,
unsafe_math: true,
unsafe_symbols: true,
unsafe_methods: true,
unsafe_proto: true,
unsafe_regexp: true,
unsafe_undefined: true,
},
mangle: {
properties: {
// Shorten internal-only props, but don't change `_`
regex: /^_./,
},
},
// some sort of type mismatch between plugins
}) as any,
],
})