-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
73 lines (68 loc) · 1.44 KB
/
vite.config.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import path from 'node:path'
import { defineConfig, loadEnv } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
type Env = Record<string, string>
const config = {
production: (env: Env) => ({
define: {
'import.meta.vitest': 'undefined'
},
build: {
manifest: true,
minify: true,
reportCompressedSize: true,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
fileName: 'index',
formats: ['es', 'cjs', 'umd', 'iife'],
name: 'lastroUtils',
},
rollupOptions: {
external: ['lodash', 'moment', 'numbro', 'papaparse', 'uuid'],
output: {
globals: {
lodash: '_',
moment: 'moment',
numbro: 'numbro',
papaparse: 'Papa',
uuid: 'uuid',
},
},
},
},
}),
development: (env: Env) => ({
build: {
target: 'esnext',
},
server: {
port: 3000,
},
}),
test: (env: Env) => ({
build: {
target: 'esnext',
},
server: {
port: 3000,
},
test: {
coverage: {
provider: 'c8'
},
includeSource: ['src/**/*.ts']
}
}),
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [
tsconfigPaths(),
],
define: {
'__APP_VERSION__': JSON.stringify(process.env.npm_package_version)
},
...config[mode](env),
}
})