-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrollup.config.js
61 lines (55 loc) · 1.42 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
import path from "path";
import commonjs from "rollup-plugin-commonjs"; // commonjs模块转换插件
import { eslint } from "rollup-plugin-eslint"; // eslint插件
import resolve from "rollup-plugin-node-resolve"; // 依赖引用插件
import postcss from "rollup-plugin-postcss";
import ts from "rollup-plugin-typescript2";
import { uglify } from "rollup-plugin-uglify";
import packageJSON from "./package.json";
const getPath = (_path) => path.resolve(__dirname, _path);
const extensions = [".js", ".ts", ".tsx"];
// ts
const tsPlugin = ts({
tsconfig: getPath("./tsconfig.json"), // 导入本地ts配置
extensions,
});
// eslint
const esPlugin = eslint({
throwOnError: true,
include: ["src/**/*.ts"],
exclude: ["node_modules/**", "lib/**"],
});
// 基础配置
const commonConf = {
input: getPath("./doc/src/package/index.tsx"),
external: ["react","react-dom","antd","@ant-design/icons","react-grid-layout"],
plugins: [
uglify(),
postcss(),
resolve(extensions),
// babel({
// exclude: 'node_modules/**' // 仅仅转译我们的源码
// }),
commonjs(),
esPlugin,
tsPlugin,
],
};
export default [
{
...commonConf,
output: {
name: packageJSON.name,
file: packageJSON.main, // 通用模块
format: "umd",
},
},
{
...commonConf,
output: {
name: packageJSON.name,
file: packageJSON.module, // es6模块
format: "es",
},
}
];