-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
60 lines (57 loc) · 1.68 KB
/
rollup.config.mjs
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
// rollup.config.mjs
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from 'rollup-plugin-typescript2'
import { terser } from 'rollup-plugin-terser'
import { uglify } from 'rollup-plugin-uglify'
import dts from 'rollup-plugin-dts'
import pkg from './package.json' assert { type: 'json' }
const defineLib = ({ input, outputName }) => {
return [
{
input,
external: ['react'],
output: [
{ file: `dist/${outputName}.cjs.js`, format: 'cjs' },
{ file: `dist/${outputName}.esm.js`, format: 'es' }
],
plugins: [
typescript(),
commonjs(), // so Rollup can convert `ms` to an ES module
...(process.env.NODE_ENV === 'development' ? [] : [terser(), uglify()])
]
},
// 声明
{
input,
external: ['react', '@nextui-org/react', 'antd', '@mui/material'],
output: [
{
file: `dist/${outputName}.d.ts`
}
],
plugins: [dts()]
}
]
}
/** @type {import('rollup').RollupOptions} */
export default [
{
input: 'src/forUmd.ts',
output: {
name: 'hookFormReact',
file: pkg.browser,
format: 'umd'
},
external: ['react', '@nextui-org/react', 'antd'],
plugins: [
typescript(),
resolve(), // so Rollup can find `ms`
commonjs(), // so Rollup can convert `ms` to an ES module
...(process.env.NODE_ENV === 'development' ? [] : [terser(), uglify()])
]
},
...defineLib({ input: 'src/Antd_5/index.tsx', outputName: 'Antd_5' }),
...defineLib({ input: 'src/MUI_5/index.ts', outputName: 'MUI_5' }),
...defineLib({ input: 'src/index.ts', outputName: 'index' })
]