-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathrollup.config.js
54 lines (46 loc) · 928 Bytes
/
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
import { terser } from "rollup-plugin-terser";
import { getBabelOutputPlugin as babel } from '@rollup/plugin-babel';
const BASE_FILENAME = "stretchy";
const IIFE_NAME = "Stretchy";
function bundle(format, {minify} = {}) {
let filename = BASE_FILENAME;
if (format !== "esm") {
filename += "." + format;
}
if (minify) {
filename += ".min";
}
let plugins = [
babel({
presets: ["@babel/preset-env"],
allowAllFormats: true,
})
];
if (minify) {
plugins.push(
terser({
compress: true,
mangle: true
})
);
}
return {
file: `dist/${filename}.js`,
name: IIFE_NAME,
format: format,
sourcemap: format !== "esm",
plugins
};
}
// Same as a rollup.config.js
export default {
input: "src/" + BASE_FILENAME + ".js",
output: [
bundle("iife"),
bundle("iife", {minify: true}),
bundle("esm"),
bundle("esm", {minify: true}),
bundle("cjs"),
bundle("cjs", {minify: true})
],
};