-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrollup.config.ts
More file actions
67 lines (63 loc) · 1.49 KB
/
rollup.config.ts
File metadata and controls
67 lines (63 loc) · 1.49 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import external from "rollup-plugin-peer-deps-external";
import terser from "@rollup/plugin-terser";
import typescript from "rollup-plugin-typescript2";
import { defineConfig, InputPluginOption } from "rollup";
import { type Plugin } from "rollup";
import * as fs from "fs";
const input = "src/index.ts";
const cleanDist: Plugin = {
name: "cleanDist",
/**
* Remove some unwanted files from the dist folder before creating the bundle
*/
writeBundle() {
fs.rmSync("./dist/rollup.config.d.ts", { force: true });
fs.rmSync("./dist/jest.config.d.ts", { force: true });
fs.rmSync("./dist/eslint.config.d.ts", { force: true });
},
};
const plugins = [
external({
includeDependencies: true,
}) as InputPluginOption,
typescript({
clean: true,
exclude: ["**/__tests__", "**/*.test.ts", "**/stories/**/*", "**/coverage"],
}),
commonjs({
include: /\/node_modules\//,
}),
nodeResolve(),
terser({
output: { comments: false },
compress: {
drop_console: true,
},
}),
cleanDist,
];
export default defineConfig([
{
input,
output: {
file: "dist/index.js",
format: "cjs",
sourcemap: true,
exports: "named",
interop: "auto",
},
plugins,
},
{
input,
output: {
file: "dist/index.modern.js",
format: "esm",
sourcemap: true,
exports: "named",
},
plugins,
},
]);