-
Notifications
You must be signed in to change notification settings - Fork 10
/
rollup.config.js
48 lines (45 loc) · 1.03 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
// 引入path
const path = require("path");
// 使用插件
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import { uglify } from "rollup-plugin-uglify";
// 引入package.json
import pkg from "./package.json";
// 获得文件全路径
function pathResolve(dir) {
return path.resolve(__dirname, dir);
}
// 声明注释
const banner = `/*!
* ${pkg.name} v${pkg.version}
* Copyright 2021-${new Date().getFullYear()}, ${pkg.author}
* Released under the ${pkg.license} License.
*/`;
/**
* rollup 配置
*/
export default {
// 入口
input: pathResolve("./index.js"),
// 输出
output: [
// 开发版js
{
file: pathResolve(`./dist/index.js`),
format: "umd", // 输出模式
name: pkg.moduleName,
banner,
},
// 压缩版js
{
file: pathResolve(`./dist/index.min.js`),
format: "umd", // 输出模式
name: pkg.moduleName,
banner,
plugins: [uglify()],
},
],
// 使用插件
plugins: [resolve(), commonjs()],
};