-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
83 lines (81 loc) · 2.12 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import path from "path";
import { DEFAULT_EXTENSIONS } from "@babel/core";
import pkg from "./package.json";
import resolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import external from "rollup-plugin-peer-deps-external";
import del from "rollup-plugin-delete";
import typescript from "rollup-plugin-typescript2";
import commonjs from "@rollup/plugin-commonjs";
import svgr from "@svgr/rollup";
import url from "rollup-plugin-url";
import postcss from "rollup-plugin-postcss";
import dts from "rollup-plugin-dts";
import { terser } from "rollup-plugin-terser";
export default [
{
input: pkg.source,
output: [
{ file: pkg.main, format: "cjs", exports: "named", sourcemap: true },
{ file: pkg.module, format: "esm", exports: "named", sourcemap: true },
],
plugins: [
del({ targets: ["dist/*"] }),
external({
includeDependencies: true,
}),
resolve({
browser: true,
moduleDirectories: ["node_modules", "src"],
exclude: ["src/__tests__"],
}),
typescript({
declaration: true,
tsconfigOverride: {
exclude: ["node_modules", "**/__tests__"],
},
}),
commonjs({
include: ["node_modules/**"],
}),
babel({
exclude: ["node_modules/**"],
extensions: [...DEFAULT_EXTENSIONS, ".ts", ".tsx"],
}),
postcss({
minimize: true,
extract: "assets/styles/index.css",
modules: {
globalModulePaths: [/^((?!module.css)[\s\S])*$/],
},
}),
url({
fileName: "[dirname][hash][extname]",
sourceDir: path.join(__dirname, "src"),
}),
svgr({
svgoConfig: {
plugins: {
removeViewBox: false,
},
},
}),
terser({
compress: true,
}),
],
external: Object.keys(pkg.peerDependencies || {}),
},
{
input: pkg.source,
output: [{ file: pkg.types, format: "es" }],
external: [/\.scss$/, /\.css$/],
plugins: [
dts({
compilerOptions: {
baseUrl: "./src",
},
}),
],
},
];