-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrollup.config.js
80 lines (71 loc) · 2 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// 为了让rollup识别commonjs类型的包,默认只支持导入ES6
import commonjs from 'rollup-plugin-commonjs';
// 为了支持import xx from 'xxx'
import nodeResolve from 'rollup-plugin-node-resolve';
// ts转js的编译器
import typescript from 'rollup-plugin-typescript';
// 支持加载json文件
import json from 'rollup-plugin-json';
// 支持字符串替换, 比如动态读取package.json的version到代码
import replace from 'rollup-plugin-replace';
// 读取package.json
import pkg from './package.json';
// 代码生成sourcemaps
import sourceMaps from 'rollup-plugin-sourcemaps'
import alias from 'rollup-plugin-alias'
// 代码头
const banner =
`/*!
* AnyTouch.js v${pkg.version}
* (c) 2019-${new Date().getFullYear()} Russell
* https://github.com/any86/vue-create-root
* Released under the MIT License.
*/`
export default {
input: './src/main.ts',
plugins: [
// alias({
// 'vue': 'vue/dist/vue.esm'
// }),
replace({
__VERSION__: pkg.version,
__PKG_NAME__: pkg.name,
}),
typescript({
exclude: 'node_modules/**',
typescript: require('typescript'),
}),
json(),
nodeResolve({
jsnext: true,
main: true
}),
commonjs({
include: 'node_modules/**'
}),
sourceMaps(),
],
output: [{
format: 'cjs',
// 生成的文件名和路径
// package.json的main字段, 也就是模块的入口文件
file: pkg.main,
banner,
sourcemap: true
},
{
format: 'es',
// rollup和webpack识别的入口文件, 如果没有该字段, 那么会去读取main字段
file: pkg.module,
banner,
sourcemap: true
},
{
format: 'umd',
name: 'createRoot',
file: pkg.browser,
banner,
sourcemap: true
}
]
};