-
Notifications
You must be signed in to change notification settings - Fork 10
/
rollup.config.js
109 lines (101 loc) · 2.33 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
105
106
107
108
109
import path from "node:path";
import babel from "@rollup/plugin-babel";
import terser from "@rollup/plugin-terser";
import copy from "rollup-plugin-copy";
/**
* @typedef {import("rollup").RollupOptions} RollupOptions
* @typedef {import("rollup").RollupOptionsFunction} RollupOptionsFunction
*/
const {
npm_package_name: NAME,
npm_package_version: VERSION,
npm_package_homepage: HOMEPAGE,
npm_package_license: LICENSE,
} = process.env;
const YEAR = new Date().getFullYear();
/** @type {RollupOptions} */
const defaultConfig = {
input: "src/index.js",
output: [
{
file: `dist/node/${NAME}.cjs`,
format: "cjs",
sourcemap: true,
},
{
file: `dist/module/${NAME}.js`,
format: "module",
sourcemap: true,
},
{
file: `dist/module/${NAME}.min.js`,
format: "module",
plugins: [terser()],
},
{
file: `dist/browser/${NAME}.iife.js`,
format: "iife",
name: NAME,
banner: `/*! ${NAME} v${VERSION} | (c) 2015-${YEAR} (${LICENSE}) | ${HOMEPAGE} */`,
sourcemap: true,
},
{
file: `dist/browser/${NAME}.iife.min.js`,
format: "iife",
name: NAME,
plugins: [terser()],
},
],
plugins: [
babel({
babelHelpers: "runtime",
}),
copy({
targets: [
{
src: path.resolve("./src/stylesheets/core.css"),
dest: path.resolve("dist/"),
rename: "mathup.css",
},
],
}),
],
};
/** @type {RollupOptions} */
const customElementConfig = {
input: "src/custom-element.js",
output: [
{
file: `dist/module/math-up-element.js`,
format: "module",
sourcemap: true,
},
{
file: `dist/module/math-up-element.min.js`,
format: "module",
plugins: [terser()],
},
{
file: `dist/browser/math-up-element.iife.js`,
format: "iife",
name: "MathUpElement",
banner: `/*! ${NAME} v${VERSION} | (c) 2015-${YEAR} (${LICENSE}) | ${HOMEPAGE} */`,
sourcemap: true,
},
{
file: `dist/browser/math-up-element.iife.min.js`,
format: "iife",
name: "MathUpElement",
plugins: [terser()],
},
],
plugins: [
babel({
babelHelpers: "runtime",
}),
],
};
/** @type {RollupOptionsFunction} */
export default function rollup() {
return [defaultConfig, customElementConfig];
}