-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
82 lines (80 loc) · 1.76 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
82
import typescript from 'rollup-plugin-typescript';
import PrototypeMinify from "rollup-plugin-prototype-minify";
import replace from "rollup-plugin-replace";
import { uglify } from "rollup-plugin-uglify";
const pkg = require("./package.json");
const banner = require("./config/banner");
const merge = require("./config/merge");
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 /@version/.test(text);
}
},
},
});
const defaultConfig = {
plugins: [
plugin,
replace({
"#__VERSION__#": pkg.version,
"/** @class */": "/*#__PURE__*/",
delimiters: ["", ""],
}),
PrototypeMinify({ sourcemap: true })
],
output: {
banner,
format: "es",
freeze: false,
exports: "named",
interop: false,
sourcemap: true,
},
};
export default [
{
input: 'src/index.ts',
output: {
file: `./dist/shapetri.esm.js`,
},
}, {
input: 'src/index.ts',
output: {
format: "cjs",
file: `./dist/shapetri.common.js`,
},
}, {
input: 'src/index.umd.ts',
output: {
format: "umd",
name: "ShapeTri",
exports: "default",
file: `./dist/shapetri.js`,
},
}, {
input: 'src/index.umd.ts',
plugins: [uglifyCode],
output: {
format: "umd",
name: "ShapeTri",
exports: "default",
file: `./dist/shapetri.min.js`,
},
}
].map(entry => merge(defaultConfig, entry, {
plugins: "append",
output: "append",
}));