forked from L2ncE/juejin-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
60 lines (49 loc) · 1.59 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
import path from "path";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import dts from "rollup-plugin-dts";
import workspacesRun from "workspaces-run";
// const isProduction = process.env.NODE_ENV === "production";
async function run() {
const compiled = new Date().toUTCString().replace(/GMT/g, "UTC");
const results = [];
const packages = [];
await workspacesRun({ cwd: __dirname, orderByDeps: true }, async pkg => {
if (!pkg.config.private) {
packages.push(pkg);
}
});
packages.forEach(pkg => {
const { version, source, main, module, types, dependencies, devDependencies } = pkg.config;
const banner = [
`/*!`,
` * ${pkg.name} - v${version}`,
` * Compiled ${compiled}`,
` *`,
` * ${pkg.name} is licensed under the Apache License Version 2.0.`,
` * https://opensource.org/licenses/Apache-2.0`,
` */`
].join("\n");
const basePath = path.relative(__dirname, pkg.dir);
const input = path.join(basePath, source);
results.push({
input,
external: [...Object.keys(dependencies), ...Object.keys(devDependencies)],
output: [
{ banner, file: path.join(basePath, main), format: "cjs" },
{ banner, file: path.join(basePath, module), format: "esm" }
],
plugins: [commonjs(), typescript()],
watch: {
exclude: "node_modules"
}
});
results.push({
input,
output: [{ banner, file: path.join(basePath, types), format: "esm" }],
plugins: [dts()]
});
});
return results;
}
export default run();