generated from innei-template/rollup-typescript-lib
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.mts
66 lines (62 loc) · 1.57 KB
/
vite.config.mts
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { readFileSync, writeFileSync } from 'fs'
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import react from '@vitejs/plugin-react'
import { preserveDirectives } from 'rollup-plugin-preserve-directives'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
const packageJson = JSON.parse(
readFileSync('./package.json', { encoding: 'utf-8' }),
)
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const globals = {
// @ts-ignore
...(packageJson?.dependencies || {}),
}
// eslint-disable-next-line import/no-default-export
export default defineConfig({
plugins: [
react(),
dts({
// rollupTypes: true
insertTypesEntry: true,
beforeWriteFile: (filePath, content) => {
writeFileSync(filePath.replace('.d.ts', '.d.mts'), content)
return { filePath, content }
},
}),
],
resolve: {
alias: {
'~': resolve(__dirname, './src'),
},
},
build: {
lib: {
entry: [
resolve(__dirname, 'src/index.ts'),
resolve(__dirname, 'src/helpers/m.tsx'),
resolve(__dirname, 'src/helpers/motion.tsx'),
resolve(__dirname, 'src/helpers/mobile-detector.tsx'),
],
name: 'RcModal',
},
rollupOptions: {
external: [
'react',
'react-dom',
'lodash',
'lodash-es',
'react/jsx-runtime',
...Object.keys(globals),
],
output: {
globals: {
RcModal: 'RcModal',
},
preserveModules: true,
},
plugins: [preserveDirectives({})],
},
},
})