-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.js
39 lines (36 loc) · 981 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
import packageDefinition from './package.json' assert {type: 'json'}
import * as fs from "node:fs";
import {resolve} from "path";
import {defineConfig} from "vite";
export default defineConfig({
build: {
outDir: '.',
sourcemap: true,
lib: {
entry: resolve(__dirname, 'src/index.jsx'),
name: 'super-react-gist',
formats: ['cjs', 'umd', 'umd', 'es'],
fileName: (moduleFormat) => {
const directory = {
cjs: 'lib',
umd: 'umd',
es: 'es'
}[moduleFormat]
const fileName = moduleFormat === 'umd' ? packageDefinition.name : 'index'
const filePath = `${directory}/${fileName}.js`
return !fs.existsSync(filePath) ? filePath : `${directory}/${fileName}.min.js`
}
},
rollupOptions: {
external: ['react', 'react-dom'],
output: {
globals: {
gist: 'Gist'
}
},
}
},
resolve: {
dedupe: ['react', 'react-dom'],
},
})