-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
81 lines (78 loc) · 1.67 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
81
import typescript from 'rollup-plugin-typescript';
import PrototypeMinify from "rollup-plugin-prototype-minify";
import { uglify } from "rollup-plugin-uglify";
import es3 from "rollup-plugin-es3";
const merge = require("./config/merge");
const banner = require("./config/banner");
const plugin = typescript({
"module": "es2015",
"target": "es3",
"lib": ["es2015", "dom"],
"exclude": "node_modules/**",
"sourceMap": true,
});
const uglifyCode = uglify({
sourcemap: true,
output: {
comments: function (node, comment) {
var text = comment.value;
var type = comment.type;
if (type === "comment2") {
// multiline comment
return /@name\:\s@daybrush/.test(text);
}
},
},
});
const defaultConfig = {
plugins: [
plugin, PrototypeMinify({sourcemap: true}),
],
output: {
banner,
format: "es",
freeze: false,
exports: "named",
interop: false,
sourcemap: true,
},
};
export default [
{
input: 'src/index.ts',
output: {
file: `./dist/utils.esm.js`,
},
},
{
input: 'src/index.ts',
output: {
exports: "named",
format: "cjs",
file: `./dist/utils.cjs.js`,
},
},
{
input: 'src/index.umd.ts',
plugins: [es3({sourcemap: true})],
output: {
exports: "default",
format: "umd",
name: "utils",
file: `./dist/utils.js`,
},
},
{
input: 'src/index.umd.ts',
plugins: [es3({sourcemap: true}), uglifyCode],
output: {
exports: "default",
format: "umd",
name: "utils",
file: `./dist/utils.min.js`,
},
},
].map(entry => merge(defaultConfig, entry, {
plugins: "append",
output: "append",
}));