-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
41 lines (39 loc) · 971 Bytes
/
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
import { copyFile } from 'fs/promises'
import { resolve } from 'path'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
const PROD =
process.env.NODE_ENV === 'production' &&
process.env.BUILD_ENV !== 'development'
export default defineConfig({
build: {
outDir: 'dist',
lib: {
name: 'WikiSaikou',
fileName: 'index',
entry: resolve(import.meta.dirname, 'src/index.ts'),
formats: ['umd', 'cjs', 'es', 'iife'],
},
sourcemap: true,
},
esbuild: {
drop: PROD ? ['console'] : [],
},
define: {
// @FIX Uncaught ReferenceError: process is not defined
// @link https://github.com/vitejs/vite/issues/9186
'process.env.NODE_ENV': '"production"',
},
plugins: [
dts(),
{
name: 'cts',
closeBundle() {
copyFile(
resolve(import.meta.dirname, 'dist/index.d.ts'),
resolve(import.meta.dirname, 'dist/index.d.cts')
)
},
},
],
})