-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
43 lines (42 loc) · 1.22 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
/** 将json转换为ES6模块 */
import json from '@rollup/plugin-json'
/** 引入package.json文件 */
import pkg from './package.json'
/** rollup解析及编译TS插件 */
import typescript from 'rollup-plugin-typescript2'
/** 解析代码中依赖的node_modules */
import resolve from '@rollup/plugin-node-resolve'
/** 将 CommonJS 模块转换为 ES6 的 Rollup 插件 */
import commonjs from '@rollup/plugin-commonjs'
/** rollup文件夹清除插件 */
import { cleandir } from 'rollup-plugin-cleandir'
/** 压缩代码 */
// import { terser } from 'rollup-plugin-terser'
export default {
input: './lib/index.ts',
output: {
name: '2',
file: pkg.main,
banner: '#!/usr/bin/env node',
format: 'umd',
},
plugins: [
/** 配置插件 - 每次打包清除目标文件 */
cleandir('./dist'),
/** 配置插件 - 将json转换为ES6模块 */
json(),
typescript({
useTsconfigDeclarationDir: true,
}),
resolve({
extensions: ['.js', '.ts', '.json'],
modulesOnly: true,
preferredBuiltins: false,
}),
commonjs({ extensions: ['.js', '.ts', '.json'] }),
],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
],
}