-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
57 lines (51 loc) · 1.39 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
import path from "path";
import { name, version } from "./package.json";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import { babel } from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import { terser } from "rollup-plugin-terser";
/**
* @desc Rollup 配置
* @type {(commandLineArgs: {_: string[];[k: string]: string | number | boolean }) => import('rollup').RollupOptions}
*/
export default (commandLineArgs) => ({
input: path.resolve(__dirname, "src/index.ts"),
plugins: [
nodeResolve({ extensions: [".ts", ".js", ".json"] }),
commonjs(),
babel({
babelHelpers: "bundled",
extensions: [".ts", ".js"],
include: ["src/**/*"],
exclude: ["node_modules"],
}),
],
output: MODULE_FORMATES.map((format) => ({
file: path.resolve(
__dirname,
`dist/${PKG_SUB_SCOPE_NAME}.${format}.min.js`
),
name: PKG_SUB_SCOPE_NAME.toLocaleUpperCase(),
plugins: [
terser({
module: true,
format: {
comments: "some",
},
}),
],
format,
banner,
inlineDynamicImports: true,
})),
});
const MODULE_FORMATES = ["cjs", "esm"];
const PKG_SUB_SCOPE_NAME = name.match(/(@\w+\/)(\w+)/)
? name.match(/(@\w+\/)(\w+)/)[2]
: "";
const banner = `/*!
* ${name} v${version}
* (c) 2022 - ${new Date().getFullYear()} luckrya
* Released under the MIT License.
*/
`;