-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
30 lines (29 loc) · 1007 Bytes
/
rollup.config.js
File metadata and controls
30 lines (29 loc) · 1007 Bytes
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
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import json from '@rollup/plugin-json';
import { visualizer } from 'rollup-plugin-visualizer';
export default {
input: './src/index.ts', // 打包入口
external: ['prettier', 'line-reader', 'ora'],
output: {
// 打包出口
dir: 'bin',
inlineDynamicImports: true, // 内联动态导入
entryFileNames: '[name].cjs',
format: 'cjs',
banner: '#! /usr/bin/env node\nglobal.navigator = {userAgent: "node.js"}', // 补丁
},
plugins: [
// 打包插件
terser({
maxWorkers: 4, // 多线程压缩
}), // 压缩打包的结果
resolve({ preferBuiltins: true }), // 查找和打包node_modules中的第三方模块
commonjs(), // 将 CommonJS 转换成 ES2015 模块供 Rollup 处理
typescript(), // 解析TypeScript
json(),
visualizer(),
],
};