forked from canonical/ubuntu.com
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.js
53 lines (49 loc) · 2.05 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
let esbuild = require("esbuild");
let entries = {
contributions: "./static/js/src/contributions.js",
"desktop-statistics": "./static/js/src/desktop-statistics.js",
tutorials: "./static/js/src/tutorials.js",
forms: "./static/js/src/forms.js",
"image-download": "./static/js/src/image-download.js",
main: "./static/js/src/main.js",
"release-chart": "./static/js/src/release-chart.js",
tabotronic: "./static/js/src/tabotronic.js",
appliance: "./static/js/src/appliance.js",
costCalculator: "./static/js/src/openstack/react/app.jsx",
"ua-payment-modal": "./static/js/src/ua-payment-modal.js",
"ua-payment-methods": "./static/js/src/ua-payment-methods.js",
"sticky-nav": "./static/js/src/sticky-nav.js",
chassisAnimation: "./static/js/src/chassis-animation.js",
cve: "./static/js/src/cve/cve.js",
productSelector: "./static/js/src/advantage/subscribe/product-selector.js",
advantageAccountUsers: "./static/js/src/advantage/users/app.jsx",
openstackChart: "./static/js/src/openstack-chart.js",
uaSubscribe: "./static/js/src/advantage/subscribe/react/app.jsx",
"cloud-price-slider": "./static/js/src/cloud-price-slider.js",
"certified-search-results": "./static/js/src/certified-search-results.js",
openstackDeploymentChart: "./static/js/src/openstack-deployment-chart.js",
};
const isDev = process && process.env && process.env.NODE_ENV === "development";
for (const [key, value] of Object.entries(entries)) {
const options = {
entryPoints: [value],
bundle: true,
minify: isDev ? false : true,
sourcemap: isDev ? false : true,
outfile: "static/js/dist/" + key + ".js",
target: ["chrome58", "firefox57", "safari11", "edge16"],
define: {
"process.env.NODE_ENV":
// Explicitly check for 'development' so that this defaults to
// 'production' in all other cases.
isDev ? '"development"' : '"production"',
},
};
esbuild
.build(options)
.then((result) => {
console.log("Built " + key + ".js");
})
// Fail the build if there are errors.
.catch(() => process.exit(1));
}