-
Notifications
You must be signed in to change notification settings - Fork 20
/
rollup.config.mjs
98 lines (94 loc) · 2.48 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
import buble from "@rollup/plugin-buble";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import typescript from "@rollup/plugin-typescript";
import filesize from "rollup-plugin-filesize";
import { uglify } from "rollup-plugin-uglify";
const MODULE_NAME = "AlgoliaAnalytics";
const LIBRARY_OUTPUT_NAME = "search-insights";
const createPlugins = ({ format, flavor }) => [
typescript(),
resolve({
preferBuiltins: false
}),
json({
preferConst: true,
compact: true
}),
replace({
preventAssignment: true,
__DEV__:
format === "umd" || format === "iife" || format === "esm"
? false
: 'process.env.NODE_ENV === "development"',
__FLAVOR__: JSON.stringify(flavor),
exclude: ["package.json"]
}),
buble(),
commonjs(),
...(["node-cjs", "node-esm"].includes(flavor) ? [] : [uglify()]),
filesize()
];
export default [
{
input: "lib/entry-umd.ts",
output: {
format: "umd",
exports: "named",
name: MODULE_NAME,
file: `./dist/${LIBRARY_OUTPUT_NAME}.min.js`,
globals: {}
},
plugins: createPlugins({ format: "umd", flavor: "browser-umd" })
},
{
input: "lib/entry-node.ts",
output: {
format: "cjs",
exports: "named",
name: MODULE_NAME,
file: `./dist/${LIBRARY_OUTPUT_NAME}-node.cjs`
},
external: ["http", "https"],
plugins: createPlugins({ format: "cjs", flavor: "node-cjs" })
},
{
input: "lib/entry-browser.ts",
output: {
format: "cjs",
exports: "named",
name: MODULE_NAME,
file: `./dist/${LIBRARY_OUTPUT_NAME}-browser.min.cjs`
},
external: ["http", "https"],
plugins: createPlugins({ format: "cjs", flavor: "browser-cjs" })
},
{
input: "lib/entry-umd.ts",
output: {
format: "iife",
exports: "named",
name: MODULE_NAME,
file: `./dist/${LIBRARY_OUTPUT_NAME}.iife.min.js`
},
plugins: createPlugins({ format: "iife", flavor: "browser-iife" })
},
{
input: "lib/entry-browser.ts",
output: {
format: "esm",
file: `./dist/${LIBRARY_OUTPUT_NAME}-browser.mjs`
},
plugins: createPlugins({ format: "esm", flavor: "browser-esm" })
},
{
input: "lib/entry-node.ts",
output: {
format: "esm",
file: `./dist/${LIBRARY_OUTPUT_NAME}-node.mjs`
},
plugins: createPlugins({ format: "esm", flavor: "node-esm" })
}
];