-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
56 lines (52 loc) · 1.24 KB
/
rollup.config.mjs
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
/*
* @Author: Rikka
* @Date: 2022-05-07 17:12:35
* @LastEditTime: 2022-05-11 11:30:00
* @LastEditors: Rikka
* @Description:
* @FilePath: \faw-operate-plateform-workspace\apps\tools\upload\rollup.config.js
*/
import typescript from "rollup-plugin-typescript2";
import hashbang from "rollup-plugin-hashbang";
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
import { resolve } from "path";
import { rmdirSync } from "fs";
function rollupBuildUtil() {
return {
name: "build-util",
buildStart() {
rmdirSync(resolve(process.cwd(), "dist"), { recursive: true });
}
};
}
const plugins = [
nodeResolve({
preferBuiltins: true,
exportConditions: ["node"],
moduleDirectories: ["node_modules"],
resolveOnly: (module) => !module.includes("ssh2")
}),
commonjs(),
rollupBuildUtil(),
typescript(),
json(),
replace({
"require('node:": "require('"
}),
// hashbang.default()
];
const config = [
{
input: "src/bin.ts",
output: {
format: "cjs",
banner: "#!/usr/bin/env node",
file: "./dist/bin.js"
},
plugins
}
];
export default config;