-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
36 lines (36 loc) · 1010 Bytes
/
vite.config.ts
File metadata and controls
36 lines (36 loc) · 1010 Bytes
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
import { defineConfig } from 'vite'
import { readFileSync } from 'node:fs'
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'))
export default defineConfig(({ mode }) => {
return {
build: {
outDir: 'dist',
emptyOutDir: true,
lib: {
entry: ['src/simapi.core.ts', 'src/simapi.pinia.ts'],
name: 'SimApi',
formats: ['es', 'cjs'],
fileName: (format, entryName) => {
if (entryName === 'simapi.core') {
return `index.${format === 'es' ? 'mjs' : 'cjs'}`
} else if (entryName === 'simapi.pinia') {
return `pinia.${format === 'es' ? 'mjs' : 'cjs'}`
}
return `${entryName}.${format === 'es' ? 'mjs' : 'cjs'}`
}
},
rollupOptions: {
external: ['vue', 'pinia'],
output: {
globals: {
vue: 'Vue',
pinia: 'Pinia'
}
}
}
},
define: {
SimApiVersion: JSON.stringify(pkg.version)
}
}
})