-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
44 lines (43 loc) · 1.04 KB
/
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
42
43
44
import * as path from 'node:path'
import * as vite from 'vite'
export default vite.defineConfig({
root: process.argv[2] ? undefined : 'demo',
resolve: {
alias: {
shaderkit: path.resolve(__dirname, './src'),
},
},
build: {
target: 'es2018',
sourcemap: true,
lib: {
formats: ['es', 'cjs'],
entry: 'src/index.ts',
fileName: '[name]',
},
rollupOptions: {
external: (id: string) => !id.startsWith('.') && !path.isAbsolute(id),
output: {
sourcemapExcludeSources: true,
},
},
},
plugins: [
{
name: 'vite-tsc',
generateBundle(options) {
const ext = options.format === 'cjs' ? 'cts' : 'ts'
this.emitFile({ type: 'asset', fileName: `index.d.${ext}`, source: `export * from '../src'` })
},
},
{
name: 'vite-minify',
renderChunk: {
order: 'post',
handler(code, { fileName }) {
return vite.transformWithEsbuild(code, fileName, { minify: true, target: 'es2018' })
},
},
},
],
})