-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
68 lines (65 loc) · 1.64 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
import typescript from "rollup-plugin-typescript2";
import { terser } from "rollup-plugin-terser";
import dts from "rollup-plugin-dts";
import copy from "rollup-plugin-copy-watch";
import del from "rollup-plugin-delete";
import pkg from "./package.json";
const mainTsName = "main";
export default [{
input: `src/ts/${mainTsName}.ts`,
output: [{
file: pkg.main,
format: "umd",
name: "SimpleTimeline",
}, {
file: pkg.module,
format: 'es',
}],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
],
plugins: [
typescript({
typescript: require("typescript"),
useTsconfigDeclarationDir: true,
}),
copy({
targets: [
{
src: "src/css/timeline.css",
dest: "dist",
rename: `${pkg.name}.css`
},
],
watch: "src/css",
verbose: true,
}),
],
}, {
input: pkg.main,
output: [
{ file: minifiedName(pkg.main), format: "umd" },
{ file: minifiedName(pkg.module), format: "es" },
],
plugins: [terser()],
}, {
input: `dist/types/${mainTsName}.d.ts`,
output: [{
file: `dist/${pkg.name}.d.ts`,
format: "umd",
}],
plugins: [
dts(),
del({
targets: "dist/types",
hook: "buildEnd",
verbose: true,
}),
],
}];
function minifiedName(name) {
const parts = name.split(".");
parts.splice(parts.length - 1, 0, "min");
return parts.join(".");
}