-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
71 lines (68 loc) · 1.94 KB
/
vite.config.js
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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteSingleFile } from 'vite-plugin-singlefile'
import { resolve } from 'path'
import dts from 'vite-plugin-dts'
// 'lib' | 'demo'
const target = process.env.TARGET ?? 'lib'
console.log('TARGET:', target)
// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
if (command === 'serve') {
return {
plugins: [ vue(), viteSingleFile() ],
root: './demo',
base: '',
resolve: {
alias: {
'@': resolve(__dirname, './src'),
}
}
}
} else if (target === 'demo') {
return {
plugins: [
viteSingleFile()
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
}
},
root: resolve(__dirname, './demo')
}
} else if (target === 'lib') {
return {
build: {
outDir: 'dist',
sourcemap: false,
commonjsOptions: {
esmExternals: true
},
skipDiagnostics: false,
lib: {
entry: resolve(__dirname, 'src/index.ts'),
formats: [ 'es', 'cjs', 'umd', 'iife' ],
name: 'OpensipsJS',
fileName: (format) => {
return `opensips-js.${format}.js`
},
}
},
plugins: [
dts({
rollupTypes: true,
copyDtsFiles: true
}),
vue(),
viteSingleFile()
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
}
},
base: './',
}
}
})