forked from ErdongChen-Andrew/CharacterControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
47 lines (43 loc) · 1.09 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
import { defineConfig } from 'vite'
import * as path from 'node:path'
import react from '@vitejs/plugin-react'
const isCodeSandbox = 'SANDBOX_URL' in process.env || 'CODESANDBOX_HOST' in process.env
const dev = defineConfig({
plugins: [react()],
root: 'example/',
publicDir: '../public/',
base: './',
server: {
host: true,
open: !isCodeSandbox, // Open if it's not a CodeSandbox
},
})
const build = defineConfig({
publicDir: false,
build: {
minify: false,
sourcemap: true,
target: 'es2018',
lib: {
formats: ['cjs', 'es'],
entry: 'src/Ecctrl.tsx',
fileName: '[name]',
},
rollupOptions: {
external: (id) => !id.startsWith('.') && !path.isAbsolute(id),
output: {
sourcemapExcludeSources: true,
},
},
},
plugins: [
{
name: 'vite-tsc',
generateBundle(options) {
const ext = options.format === 'es' ? 'ts' : 'cts'
this.emitFile({ type: 'asset', fileName: `Ecctrl.d.${ext}`, source: `export * from '../src/Ecctrl.tsx'` })
},
},
]
})
export default process.argv[2] ? build : dev