forked from jackocnr/intl-tel-input
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
111 lines (101 loc) · 2.41 KB
/
build.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
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
const { build } = require("esbuild");
const packageJson = require("./package.json");
const getBanner = (moduleName) =>
"/*\n" +
` * International Telephone Input v${packageJson.version}\n` +
` * ${packageJson.repository.url}\n` +
" * Licensed under the MIT license\n" +
" */\n\n" +
// we can remove this UMD hack once it is supported by esbuild: https://github.com/evanw/esbuild/issues/507
"// UMD\n" +
"(function(factory) {\n" +
" if (typeof module === 'object' && module.exports) {\n" +
" module.exports = factory();\n" +
" } else {\n" +
` window.${moduleName} = factory();\n` +
" }\n" +
"}(() => {\n";
const footer =
"\n// UMD\n" +
" return factoryOutput.default;\n" +
"}));";
const shared = {
bundle: true,
logLevel: "info",
format: "iife",
globalName: "factoryOutput",
footer: {
js: footer,
},
define: {
"process.env.VERSION": `"${packageJson.version}"`,
},
};
//* build/js/intlTelInput.js
build({
...shared,
banner: {
js: getBanner("intlTelInput"),
},
entryPoints: ["src/js/intl-tel-input.ts"],
minify: false,
outfile: "build/js/intlTelInput.js",
});
//* build/js/intlTelInput.min.js
build({
...shared,
banner: {
js: getBanner("intlTelInput"),
},
entryPoints: ["src/js/intl-tel-input.ts"],
minify: true,
outfile: "tmp/built.min.js",
});
//* build/js/data.js
build({
...shared,
banner: {
js: getBanner("allCountries"),
},
entryPoints: ["src/js/intl-tel-input/data.ts"],
minify: false,
outfile: "build/js/data.js",
});
//* build/js/data.min.js
build({
...shared,
banner: {
js: getBanner("allCountries"),
},
entryPoints: ["src/js/intl-tel-input/data.ts"],
minify: true,
outfile: "build/js/data.min.js",
});
//* build/js/intlTelInputWithUtils.js
build({
...shared,
banner: {
js: getBanner("intlTelInput"),
},
entryPoints: ["src/js/intl-tel-input/intlTelInputWithUtils.ts"],
minify: false,
outfile: "build/js/intlTelInputWithUtils.js",
});
//* build/js/intlTelInputWithUtils.min.js
build({
...shared,
banner: {
js: getBanner("intlTelInput"),
},
entryPoints: ["src/js/intl-tel-input/intlTelInputWithUtils.ts"],
minify: true,
outfile: "build/js/intlTelInputWithUtils.min.js",
});
//* build/js/i18n
build({
charset: "utf8",
entryPoints: ["src/js/intl-tel-input/i18n/**/*.ts"],
outdir: "build/js/i18n",
});