forked from runarberg/mathup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
104 lines (98 loc) · 2.23 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import babel from "rollup-plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import { terser } from "rollup-plugin-terser";
const {
npm_package_name: NAME,
npm_package_version: VERSION,
npm_package_homepage: HOMEPAGE,
npm_package_license: LICENSE,
} = process.env;
const YEAR = new Date().getFullYear();
const dependenciesConfig = {
input: "dependencies.src.mjs",
output: [
{
file: `dependencies.mjs`,
format: "esm",
},
],
plugins: [resolve(), commonjs()],
};
const defaultConfig = {
input: "src/index.mjs",
output: [
{
file: `target/node/${NAME}.cjs`,
format: "cjs",
sourcemap: true,
},
{
file: `target/module/${NAME}.mjs`,
format: "module",
sourcemap: true,
},
{
file: `target/module/${NAME}.min.mjs`,
format: "module",
plugins: [terser()],
},
{
file: `target/browser/${NAME}.iife.js`,
format: "iife",
name: NAME,
banner: `/*! ${NAME} v${VERSION} | (c) 2015-${YEAR} (${LICENSE}) | ${HOMEPAGE} */`,
sourcemap: true,
},
{
file: `target/browser/${NAME}.iife.min.js`,
format: "iife",
name: NAME,
plugins: [terser()],
},
],
plugins: [
babel({
runtimeHelpers: true,
}),
],
};
const customElementConfig = {
input: "src/custom-element.mjs",
output: [
{
file: `target/module/math-up-element.mjs`,
format: "module",
sourcemap: true,
},
{
file: `target/module/math-up-element.min.mjs`,
format: "module",
plugins: [terser()],
},
{
file: `target/browser/math-up-element.iife.js`,
format: "iife",
name: "MathUpElement",
banner: `/*! ${NAME} v${VERSION} | (c) 2015-${YEAR} (${LICENSE}) | ${HOMEPAGE} */`,
sourcemap: true,
},
{
file: `target/browser/math-up-element.iife.min.js`,
format: "iife",
name: "MathUpElement",
plugins: [terser()],
},
],
plugins: [
babel({
runtimeHelpers: true,
}),
],
};
export default function rollup(args) {
if (args.configDeps === true) {
return dependenciesConfig;
}
return [dependenciesConfig, defaultConfig, customElementConfig];
}