Repository navigation
Expand file tree
/
Copy pathbuild.js
More file actions
55 lines (51 loc) · 2.08 KB
/
Copy pathbuild.js
File metadata and controls
55 lines (51 loc) · 2.08 KB
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
let esbuild = require("esbuild");
const path = require("path");
const { sassPlugin } = require("esbuild-sass-plugin");
// prettier-ignore
let entries = {
"careerExplorer": "./static/js/career-explorer/App.tsx",
"side-navigation": "./static/js/side-navigation.js",
"forms": "./static/js/forms.js",
"prepare-form-inputs": "./static/js/prepare-form-inputs.js",
"navigation": "./static/js/navigation/main.js",
"active-nav-scroll": "./static/js/active-nav-scroll.js",
"homepage_animations": "./static/js/homepage/animations.js",
"homepage_center_animations": "./static/js/homepage/center-animations.js",
"homepage_carousel": "./static/js/homepage/carousel.js",
"scroll-section": "./static/js/scroll-section.js",
"cookie-policy-with-callback": "./static/js/cookie-policy-with-callback.js",
"canonical-cla": "./static/js/canonical-cla/app.tsx",
"table-of-contents": "./static/js/table-of-contents.js",
"watch-consent-changes": "./static/js/watch-consent-changes.js",
"events": "./static/js/events.js",
"in-page-navigation": "./static/js/in-page-navigation.js",
"prism": "./static/js/prism.js",
"early-careers-animation": "./static/js/early-careers-animation.js",
"announcement-bar": "./static/js/announcement-bar.js",
};
const isDev = process && process.env && process.env.NODE_ENV === "development";
for (const [key, value] of Object.entries(entries)) {
const options = {
entryPoints: [value],
plugins: [sassPlugin()],
bundle: true,
minify: isDev ? false : true,
nodePaths: [path.resolve(__dirname, "./static/js/src")],
sourcemap: isDev ? false : true,
outfile: "static/js/dist/" + key + ".js",
target: ["chrome90", "firefox88", "safari14", "edge90"],
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));
}