-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
42 lines (41 loc) · 1013 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
42
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { execSync } from 'child_process';
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'index.ts'),
name: 'add-lib',
fileName: 'index',
formats: ['es', 'umd'],
},
sourcemap: true,
minify: true,
reportCompressedSize: true,
chunkSizeWarningLimit: 500,
rollupOptions: {
output: {
entryFileNames: '[name].[format].js',
chunkFileNames: '[name]-[hash].[format].js',
},
},
},
// Use a hook to run TypeScript after the build
plugins: [
{
name: 'generate-types',
closeBundle() {
execSync('tsc --emitDeclarationOnly --declarationDir ./dist', {
stdio: 'inherit',
});
},
},
{
name: 'cleanup-assets',
closeBundle() {
// Remove any non-essential files from dist
execSync('rm -f ./dist/*.svg ./dist/*.map', { stdio: 'inherit' });
},
},
],
});