forked from meodai/fettepalette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
91 lines (84 loc) · 1.79 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
import { build } from "esbuild";
// Bundled CJS
build({
entryPoints: ["./src/index.ts"],
logLevel: "info",
bundle: true,
format: "cjs",
outfile: "dist/index.cjs",
});
// Bundled CJS, minified
build({
entryPoints: ["./src/index.ts"],
logLevel: "info",
bundle: true,
minify: true,
format: "cjs",
outfile: "dist/index.min.cjs",
});
// Bundled ESM
build({
entryPoints: ["./src/index.ts"],
logLevel: "info",
bundle: true,
format: "esm",
target: "es2020",
outfile: "dist/index.mjs",
});
// Bundled ESM, minified
build({
entryPoints: ["./src/index.ts"],
logLevel: "info",
bundle: true,
minify: true,
format: "esm",
target: "es2020",
outfile: "dist/index.min.mjs",
});
// Bundled IIFE
build({
entryPoints: ["./src/index.ts"],
logLevel: "info",
bundle: true,
format: "iife",
target: "node14",
globalName: "fettepalette",
outfile: "dist/index.js",
});
// Bundled IIFE, minified
build({
entryPoints: ["./src/index.ts"],
logLevel: "info",
bundle: true,
minify: true,
format: "iife",
target: "es6",
globalName: "fettepalette",
outfile: "dist/index.min.js",
});
// Bundled UMD
// Adapted from: https://github.com/umdjs/umd/blob/master/templates/returnExports.js
build({
entryPoints: ["./src/index.ts"],
logLevel: "info",
bundle: true,
format: "iife",
target: "es6",
globalName: "fettepalette",
banner: {
js: `(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
root.fettepalette = factory();
}
}
(typeof self !== 'undefined' ? self : this, function() {`,
},
footer: {
js: `return fettepalette; }));`,
},
outfile: "dist/index.umd.js",
});