-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
124 lines (120 loc) · 3.82 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import json from "@rollup/plugin-json";
import typescript from "rollup-plugin-typescript2";
import nodeResolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import license from "rollup-plugin-license";
import { dts } from "rollup-plugin-dts";
import commonjs from "@rollup/plugin-commonjs";
const NAME = "EmblaCore";
const WEB_ENTRY = "src/index.web.ts";
const RN_ENTRY = "src/index.native.ts";
const WEB_OUT_DIR = "lib/web";
const RN_OUT_DIR = "lib/react-native";
export default [
{
// Web version
input: WEB_ENTRY,
output: [
{
file: `${WEB_OUT_DIR}/embla-core.js`,
name: NAME,
format: "es",
},
{
file: `${WEB_OUT_DIR}/embla-core.min.js`,
name: NAME,
format: "es",
plugins: [
// Minify code
terser({
ecma: "2016",
module: true,
format: { comments: false },
}),
// Prepend license banner
license({
banner: {
commentStyle: "ignored",
content: { file: "BANNER.txt" },
},
}),
],
},
],
plugins: [
// Compile from TypeScript
typescript({ tsconfig: "tsconfig.web.json" }),
// Allow importing constants from package.json
json(),
// Include dependencies in output
nodeResolve(),
// Convert CommonJS dependency code to ES modules, so they can be bundled as ES module
commonjs(),
// Prepend license banner to output file
license({
banner: {
commentStyle: "ignored",
content: { file: "BANNER.txt" },
},
}),
],
},
{
// React Native version
input: RN_ENTRY,
external: [
"react",
"react-native",
"react-native-sound-player",
"@dr.pogodin/react-native-audio",
],
output: [
{
file: `${RN_OUT_DIR}/embla-core.js`,
name: NAME,
format: "es",
},
{
file: `${RN_OUT_DIR}/embla-core.min.js`,
name: NAME,
format: "es",
plugins: [
// Minify code
terser({
ecma: "2016",
module: true,
format: { comments: false },
}),
// Prepend license banner
license({
banner: {
commentStyle: "ignored",
content: { file: "BANNER.txt" },
},
}),
],
},
],
plugins: [
// Compile from typescript
typescript({ tsconfig: "tsconfig.react-native.json" }),
// Allow importing constants from package.json
json(),
// Convert CommonJS modules to ES modules, so they can be bundled
commonjs(),
// Prepend license banner to output file
license({
banner: {
commentStyle: "ignored",
content: { file: "BANNER.txt" },
},
}),
],
},
{
// Declaration files
input: `${RN_OUT_DIR}/src/index.native.d.ts`,
output: [{ file: "lib/types/embla-core.d.ts", format: "es" }],
plugins: [dts()],
},
];