-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrollup.config.js
More file actions
49 lines (48 loc) · 1.18 KB
/
rollup.config.js
File metadata and controls
49 lines (48 loc) · 1.18 KB
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
import fs from "fs";
import path from "path";
import babel from "rollup-plugin-babel";
import { terser } from "rollup-plugin-terser";
import resolve from "@rollup/plugin-node-resolve";
import { sizeSnapshot } from "rollup-plugin-size-snapshot";
const { version, license, name } = require("./package.json");
const licenseData = fs.readFileSync(path.join(process.cwd(), "LICENSE.md"), {
encoding: "utf-8"
});
const bannerPlugin = {
banner: `/**
* @license ${name} ${version}
* ${licenseData.split("\n", 1)}
* License: ${license}
*/`
};
const exportFormat = format => ({
input: "src/index.ts",
output: {
name: name.replace(/(^|-)(\w)/g, ($0, $1, $2) => $2.toUpperCase()),
format,
file: `dist/${format}/react-anchor-navigation.js`,
globals: {
react: "React"
}
},
external: ["react"],
plugins: [
resolve({
extensions: [".tsx", ".ts"]
}),
babel({
extensions: [".tsx", ".ts"],
exclude: "node_modules/**"
}),
bannerPlugin,
terser({
toplevel: true,
compress: {
unsafe: true
},
output: { comments: /@license/ }
}),
sizeSnapshot()
]
});
export default ["umd", "cjs", "esm"].map(exportFormat);