-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
39 lines (36 loc) · 1.1 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
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import { buildConfig } from "./rollup-utils.js";
import yargs from "yargs";
// 使用yargs解析命令行参数
const commandLineParameters = yargs(process.argv.slice(2)).options({
packagingFormat: {
type: "string",
alias: "pkgFormat",
default: "umd,esm,common"
},
}).argv;
const packagingFormat = commandLineParameters.packagingFormat.split(",");
export default {
input: 'packages/index.js',
output: buildConfig(packagingFormat),
plugins: [
json(),
resolve({
preferBuiltins: true,
browser: true
}),
commonjs(),
nodePolyfills(), // 添加 Node.js polyfills 支持
],
// 指定需要外部引入的模块
external: ['fs', 'path'],
// 添加警告忽略
onwarn: (warning, warn) => {
// 忽略特定警告
if (warning.code === 'CIRCULAR_DEPENDENCY') return;
warn(warning);
}
};