-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
63 lines (61 loc) · 1.75 KB
/
rollup.config.mjs
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
import { babel, getBabelOutputPlugin } from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import filesize from "rollup-plugin-filesize";
import ttypescript from "ttypescript";
const typescriptPluginConfig = {
typescript: ttypescript,
noEmitOnError: true,
sourceMap: true,
sourceRoot: "..",
tsconfig: "./tsconfig.json",
include: ["./src/**"],
exclude: ["**/*.test.ts"],
plugins: [
{ transform: "typescript-transform-paths" },
{ transform: "typescript-transform-paths", afterDeclarations: true },
],
};
export default [
{
input: "./src/index.ts",
output: {
dir: "./dist/cjs",
format: "cjs",
sourcemap: true,
sourcemapExcludeSources: true,
},
plugins: [
typescript({
...typescriptPluginConfig,
outDir: "./dist/cjs",
declarationDir: "./dist/cjs",
}),
babel({ babelHelpers: "bundled", extensions: [".js", ".ts"] }),
nodeResolve(),
commonjs(),
filesize(),
],
},
{
input: "./src/index.ts",
output: {
dir: "./dist/esm",
format: "esm",
sourcemap: true,
sourcemapExcludeSources: true,
preserveModules: true,
},
plugins: [
typescript({
...typescriptPluginConfig,
outDir: "./dist/esm",
declarationDir: "./dist/esm",
}),
getBabelOutputPlugin(),
nodeResolve(),
commonjs(),
],
},
];