-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
81 lines (78 loc) · 1.71 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import copy from "rollup-plugin-copy";
import esbuild from "rollup-plugin-esbuild";
import replace from "@rollup/plugin-replace";
import { dts } from "rollup-plugin-dts";
import pkg from "./package.json" assert { type: "json" };
const basePlugins = [
// Typescript
esbuild(),
];
function copyInkToDemoDist(name) {
return copy({
// Copy after the output is compiled
hook: "writeBundle",
targets: [
{ src: "src/core/storylets.ink", dest: `dist/${name}` },
{
src: ["src/core/storylets.ink", `dist/${name}/storylets.js`],
dest: `demo/${name}`,
},
],
});
}
export default [
// Pure ink as global
{
input: "src/entries/ink-global.ts",
plugins: [...basePlugins, copyInkToDemoDist("ink-global")],
output: [
{
file: `dist/ink-global/storylets.js`,
format: "iife",
},
],
},
// Pure ink as ES module with typings
{
input: "src/entries/ink-esm.ts",
plugins: [...basePlugins, copyInkToDemoDist("ink-esm")],
output: [
{
file: `dist/ink-esm/storylets.js`,
format: "es",
},
],
},
{
input: "src/entries/ink-esm.ts",
plugins: [dts()],
output: [
{
file: `dist/ink-esm/storylets.d.ts`,
format: "es",
},
],
},
// Calico patch
{
input: "src/entries/calico.ts",
plugins: [
...basePlugins,
// Inject version
replace({
include: "src/entries/calico.ts",
preventAssignment: true,
values: {
__version: JSON.stringify(pkg.version),
},
}),
copyInkToDemoDist("calico"),
],
output: [
{
file: `dist/calico/storylets.js`,
format: "es",
},
],
},
];