1 | import nodeResolve from "rollup-plugin-node-resolve";
|
2 | import commonjs from "rollup-plugin-commonjs";
|
3 | import json from "rollup-plugin-json";
|
4 | import babel from "rollup-plugin-babel";
|
5 |
|
6 | import packagejson from "./package.json";
|
7 |
|
8 | let config = {
|
9 | input: "-----",
|
10 | external: [
|
11 | ...Object.keys(packagejson.dependencies),
|
12 | "path", "fs", "chalk", "os", "child_process", "perf_hooks"
|
13 | ],
|
14 | output: {
|
15 | file: "----",
|
16 | format: "cjs",
|
17 |
|
18 | banner: `
|
19 | #!/usr/bin/env node
|
20 | /*----------------------------------------------
|
21 | * Generated by rollup. Written by John Schmidt.
|
22 | * Rally Tools CLI v${packagejson.version}
|
23 | *--------------------------------------------*/
|
24 | const importLazy = require("import-lazy")(require);
|
25 | `.substring(1),
|
26 |
|
27 | name: "RallyTools",
|
28 | sourcemap: true,
|
29 | },
|
30 | plugins: [
|
31 | nodeResolve({
|
32 | preferBuiltins: true,
|
33 | module: true,
|
34 |
|
35 | }),
|
36 | commonjs({
|
37 | include: "node_modules/**",
|
38 | extensions: [".js"],
|
39 | }),
|
40 | json(),
|
41 | babel({
|
42 | presets: [
|
43 | ["@babel/env", {
|
44 | "targets": {
|
45 | "node": "8.11.3",
|
46 | },
|
47 | "modules": false,
|
48 | }]
|
49 | ],
|
50 | plugins: [
|
51 | ["@babel/proposal-decorators", {legacy: true}],
|
52 | "@babel/proposal-optional-chaining",
|
53 | ],
|
54 | }),
|
55 | ],
|
56 | }
|
57 |
|
58 | function newConfig(input, output, format="cjs"){
|
59 | let newOut = {...config.output};
|
60 | newOut.file = output;
|
61 | newOut.format = format
|
62 | if(format !== "cjs"){
|
63 | newOut.banner = "";
|
64 | }
|
65 | let c = {
|
66 | ...config,
|
67 | input, output: newOut,
|
68 | }
|
69 | return c;
|
70 | }
|
71 |
|
72 | export default [
|
73 | newConfig("src/cli.js", "./bundle.js", "cjs"),
|
74 | newConfig("src/index.js", "./web.js", "umd"),
|
75 | ];
|