-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
69 lines (68 loc) · 2.08 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
import babel from "@rollup/plugin-babel";
import external from "rollup-plugin-peer-deps-external";
import del from "rollup-plugin-delete";
import { terser } from "rollup-plugin-terser";
import postcss from "rollup-plugin-postcss";
import pkg from "./package.json";
import json from "@rollup/plugin-json";
import image from "rollup-plugin-img";
import url from "postcss-url";
import typescript from "@rollup/plugin-typescript";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
export default [
{
input: "src/index.ts",
output: [
{ file: pkg.main, format: "cjs" },
{ file: pkg.module, format: "esm", exports: "named" },
],
plugins: [
json(),
image({
limit: 30000,
}),
commonjs({
include: /node_modules/,
requireReturnsDefault: "auto",
}),
babel({
exclude: "node_modules/**",
presets: ["@babel/preset-react"],
babelHelpers: "bundled",
}),
del({ targets: ["dist/*"] }),
postcss({
plugins: [
url({
url: "inline",
}),
],
config: {
path: "./postcss.config.js",
},
extensions: [".css"],
minimize: true,
inject: {
insertAt: "top",
},
}),
external(),
resolve(),
typescript(),
terser(),
],
// anything "external" will not be included into the generated bundle
// https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
external: [
"react",
"react-dom",
// regular dependencies should not be included as they will be automatically installed by the consuming application
...Object.keys(pkg.dependencies || {}),
// peer dependencies should not be included as they are expected to be provided by the consuming application
// https://nodejs.org/es/blog/npm/peer-dependencies/#the-solution-peer-dependencies
...Object.keys(pkg.peerDependencies || {}),
],
// extensions: [".js", ".jsx", ".es6", ".es", ".mjs", ".ts", ".tsx"],
},
];