-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
31 lines (28 loc) · 954 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
import {defineConfig} from 'vite';
import {readFileSync} from 'fs';
import {resolve, join, dirname} from 'path';
import {fileURLToPath} from 'url';
const currentDir = dirname(fileURLToPath(import.meta.url));
const {devDependencies, peerDependencies, camelCaseName} = JSON.parse(readFileSync(join(currentDir, 'package.json')));
export default defineConfig({
build: {
lib: {
formats: ['cjs', 'umd', 'es'],
entry: resolve(currentDir, 'src', 'lib', 'index.ts'),
name: camelCaseName,
fileName: (format) => (format === 'cjs' ? 'index.cjs' : `index.${format}.js`),
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: [...Object.keys(devDependencies || {}), ...Object.keys(peerDependencies || {})],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
// for example react: 'React'
},
},
},
},
});