-
Notifications
You must be signed in to change notification settings - Fork 438
/
vite.config.js
39 lines (36 loc) · 949 Bytes
/
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
/* eslint-disable import/no-extraneous-dependencies */
import * as fs from 'node:fs';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import dts from 'vite-plugin-dts';
const { dependencies, peerDependencies } = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
export default defineConfig({
plugins: [
react(),
dts({
rollupTypes: true,
afterBuild: () => {
// https://github.com/qmhc/vite-plugin-dts/issues/267
fs.copyFileSync('dist/index.d.ts', 'dist/index.d.cts');
},
}),
],
build: {
target: 'es2017',
lib: {
fileName: 'index',
formats: ['cjs', 'es'],
entry: 'src/index.ts',
},
emptyOutDir: true,
sourcemap: true,
minify: false,
rollupOptions: {
external: [
...Object.keys(dependencies || {}),
...Object.keys(peerDependencies || {}),
'react/jsx-runtime',
],
},
},
});