-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
145 lines (136 loc) · 3.29 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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import babel from "@rollup/plugin-babel";
import { terser } from "rollup-plugin-terser";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import { version, dependencies, license } from "./package.json";
const input = "node_modules/@ideal-postcodes/address-finder/esm/index.js";
const banner = `/**
* @license
* Ideal Postcodes <https://ideal-postcodes.co.uk>
* Copyright IDDQD Limited
* Address Finder Bundled ${version}
* Built on Address Finder ${dependencies["@ideal-postcodes/address-finder"]}
* ${license} Licence
*/`;
// Configure terser to ignore build info banner
const terserConfig = {
output: {
comments: (_, { value, type }) => {
if (type === "comment2") return /@license/i.test(value);
},
},
};
const sourceMap = false;
const babelHelpers = "bundled";
/**
* Whitelist files processed by Babel
*/
const include = [
"node_modules/@ideal-postcodes/address-finder/esm/**",
"node_modules/@ideal-postcodes/core-axios/esm/**",
"node_modules/@ideal-postcodes/core-interface/esm/**",
"node_modules/@ideal-postcodes/jsutil/esm/**",
"node_modules/capitalise-post-town/dist/**",
"node_modules/lodash/debounce.js",
"node_modules/core-js-pure/**/*",
];
const context = "window";
export default [
/**
* ESM build targeting minimum browser versions that allow [ES6 Modules](https://caniuse.com/#feat=es6-module)
*/
{
input,
context,
output: {
file: "./dist/address-finder.esm.js",
banner,
format: "esm",
exports: "named",
},
plugins: [
resolve({
preferBuiltins: true,
dedupe: ["@ideal-postcodes/jsutil"],
mainFields: ["browser", "module", "main"],
browser: true,
}),
commonjs(),
babel({
babelrc: false,
include,
sourceMap,
babelHelpers,
presets: [
["@babel/preset-env", {}]],
}),
terser(terserConfig),
],
},
/**
* UMD build that targets ie11 as base
*/
{
input,
context,
output: {
file: "./dist/address-finder.js",
banner,
format: "umd",
extend: true,
name: "IdealPostcodes",
exports: "named",
},
plugins: [
resolve({
preferBuiltins: true,
dedupe: ["@ideal-postcodes/jsutil"],
mainFields: ["browser", "module", "main"],
browser: true,
}),
commonjs(),
babel({
babelrc: false,
ignore: [/core-js/],
include,
babelHelpers,
sourceMap,
presets: [["@babel/preset-env", {}]],
}),
terser(terserConfig),
],
},
/**
* IIFE build to have script available in global scope
*/
{
input,
context,
output: {
file: "./dist/address-finder.iife.js",
banner,
format: "iife",
extend: true,
name: "IdealPostcodes",
exports: "named",
},
plugins: [
resolve({
preferBuiltins: true,
dedupe: ["@ideal-postcodes/jsutil"],
mainFields: ["browser", "module", "main"],
browser: true,
}),
commonjs(),
babel({
babelrc: false,
ignore: [/core-js/],
include,
babelHelpers,
sourceMap,
presets: [["@babel/preset-env", {}]],
}),
terser(terserConfig),
],
},
];