-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
62 lines (57 loc) · 1.71 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
import path from "path";
import alias from "@rollup/plugin-alias";
import babel from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import analyze from "rollup-plugin-analyzer";
import cleaner from "rollup-plugin-cleaner";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import { globSync } from "glob";
import { keys } from "ramda";
import packageJSON from "./package.json";
const rootResolve = require("./resolve.js");
const globals = Object.fromEntries(
keys(packageJSON.peerDependencies).map(lib => [lib, lib])
);
const buildFilesMatchPattern = 'index.{cjs.js,cjs.js.map,mjs,mjs.map}';
export default {
input: "./src/index.js",
output: [
{
inlineDynamicImports: true,
file: "dist/index.cjs.js",
format: "cjs",
sourcemap: true,
name: `neeto-hotkeys/index`,
globals,
},
{
inlineDynamicImports: true,
file: "dist/index.mjs",
format: "esm",
sourcemap: true,
name: `neeto-hotkeys/index`,
globals,
},
],
plugins: [
// To delete previously existing bundle.
cleaner({ targets: globSync(path.resolve(__dirname, "dist")) }),
// To automatically externalize peerDependencies in a rollup bundle.
peerDepsExternal(),
// To use third party modules from node_modules
resolve({
extensions: [".js", ".jsx", ".svg"],
}),
commonjs({ sourceMap: true }),
// To define aliases when bundling packages.
alias({ entries: rootResolve.alias }),
// To integrate Rollup and Babel.
babel({
babelHelpers: "runtime",
sourceMaps: true,
}),
// Analyze created bundle.
analyze({ summaryOnly: true }),
],
};