-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
63 lines (63 loc) · 1.44 KB
/
rollup.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import path from 'path';
import ts from 'rollup-plugin-typescript2';
// rollup babel插件
import babel from '@rollup/plugin-babel';
// 将CommonJS模块转换为ES6
import commonjs from '@rollup/plugin-commonjs';
// 将json 文件转换为ES6 模块
import json from '@rollup/plugin-json';
// node-resolve插件,将第三方模块转换为ES6模块
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import dts from 'rollup-plugin-dts';
import del from 'rollup-plugin-delete';
import pkg from './package.json';
const isPro = process.env.NODE_ENV === 'production';
export default [
{
input: path.resolve('./index.ts'),
output: [
{
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'esm',
},
{
file: pkg.browser,
format: 'umd',
name: 'Mutils',
},
],
plugins: [
resolve(),
commonjs(),
json(),
ts({
tsconfig: path.resolve(__dirname, './tsconfig.json'),
extensions: ['.ts', '.tsx', '.jsx', '.js'],
}),
babel({
exclude: 'node_modules/**',
babelHelpers: 'bundled',
}),
isPro && terser(),
],
},
{
input: path.resolve('./index.ts'),
output: {
file: pkg.types,
format: 'es',
},
plugins: [
dts(),
del({
targets: ['./dist/src/'],
hook: 'buildEnd',
}),
],
},
];