-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.mjs
45 lines (41 loc) · 957 Bytes
/
vite.config.mjs
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
import fs from 'node:fs/promises'
import path from 'node:path'
import dts from 'vite-plugin-dts'
import { defineConfig } from 'vitest/config'
export default defineConfig({
build: {
lib: {
entry: './src/index.ts',
formats: ['cjs', 'es'],
fileName: (format, name) => `${name}.${format === 'es' ? 'js' : 'cjs'}`,
},
minify: false,
rollupOptions: {
external: (id) => !id.startsWith('.') && !path.isAbsolute(id),
output: {
preserveModules: true,
exports: 'auto',
},
},
},
plugins: [
dts({
async afterBuild() {
await fs.writeFile(
'dist/index.d.ts',
(await fs.readFile('dist/index.d.ts'))
// eslint-disable-next-line unicorn/no-await-expression-member
.toString()
.replace(/\nexport .+/, '') + 'export = _default',
)
},
insertTypesEntry: true,
strictOutput: true,
rollupTypes: true,
}),
],
test: {
environment: 'node',
include: ['tests/**/*.test.ts'],
},
})