-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
41 lines (37 loc) · 1.04 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
const resolve = require("@rollup/plugin-node-resolve");
const commonjs = require("@rollup/plugin-commonjs");
const typescript = require("@rollup/plugin-typescript");
const babel = require("@rollup/plugin-babel");
const postcss = require("rollup-plugin-postcss");
const pkg = require("./package.json");
const external = [
"react/jsx-runtime",
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
...Object.keys(pkg.peerDependencies),
];
const baseConfig = { input: "src/index.ts", external };
module.exports = {
...baseConfig,
input: "src/index.tsx", // 入口文件
output: [
{
dir: "dist",
exports: "named",
format: "cjs",
inlineDynamicImports: true,
interop: "auto",
},
],
plugins: [
resolve(), // 解析外部依赖
commonjs({ requireReturnsDefault: true }), // 将 CommonJS 转换为 ES6
postcss({
extract: true, // 将 CSS 提取到独立文件
}),
babel({
exclude: "node_modules/**",
}),
typescript({ tsconfig: "./tsconfig.json" }),
],
};