-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
53 lines (53 loc) · 1.26 KB
/
rollup.config.js
File metadata and controls
53 lines (53 loc) · 1.26 KB
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
/*
* @Author: crli
* @Date: 2021-05-27 14:33:24
* @LastEditors: crli
* @LastEditTime: 2021-06-17 15:03:59
* @Description: file content
*/
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import typescript from 'rollup-plugin-typescript'
import { uglify } from 'rollup-plugin-uglify'
import pkg from './package.json'
const env = process.env.NODE_ENV
let config = {
input: 'src/index.ts', // 打包入口
output:[
{
name: pkg.name,
file: 'dist/crliutils.js',
format: 'umd', // umd是兼容amd/cjs/iife的通用打包格式,适合浏览器
},
{
name: pkg.name,
file: 'dist/crliutils.esm.js',
format: 'es'
}
],
plugins: [ // 打包插件
resolve(), // 查找和打包node_modules中的第三方模块
commonjs(), // 将 CommonJS 转换成 ES2015 模块供 Rollup 处理
typescript() // 解析TypeScript
]
}
if (env === 'production') {
config.output = [
{
name: pkg.name,
file: 'dist/'+ pkg.main,
format: 'umd',
},
{
name: pkg.name,
file: 'dist/'+ pkg.module,
format: 'es'
}
],
config.plugins.push(
uglify({
mangle: false // 不混淆一些代码的变量名
})
)
}
export default config