forked from cockpit-project/cockpit-podman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
48 lines (45 loc) · 1.74 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
const esbuild = require("esbuild");
const path = require("path");
const eslint = require('esbuild-plugin-linter');
const {sassPlugin } = require('esbuild-sass-plugin')
const { nodeExternalsPlugin } = require('esbuild-node-externals');
const replacePlugin = require('esbuild-plugin-replace-regex');
const production = process.env.NODE_ENV === 'production';
/* development options for faster iteration */
const useEslint = process.env.ESLINT !== '0';
const watchMode = process.env.ESBUILD_WATCH === "true" || false;
if(watchMode) {
console.log("Running in watch mode");
}
nodePaths=["node_modules", path.resolve(__dirname, 'pkg/lib')]
esbuild.build({
// Cockpit's http server is not able to load multiple JS files
bundle: true,
entryPoints: ["./src/index.js"],
// Allow external font files which live in ../../static/fonts
external: ['*.woff', '*.woff2'],
// Move all legal comments to a .LEGAL.txt file
legalComments: 'external',
loader: { ".js": "jsx" },
minify: production,
// List of directories to use when resolving import statements
nodePaths,
outdir: "./dist",
... !production ? { sourcemap: "external" } : {},
target: ['es2020'],
watch: watchMode,
plugins: [
sassPlugin({
loadPaths: nodePaths, quietDeps: true
}),
... useEslint ? [eslint({ filter: /src\/*/ })] : [],
nodeExternalsPlugin(),
replacePlugin({
filter: /patternfly-4-cockpit.scss$/,
patterns: [
[/@font-face[^}]*patternfly-fonts-fake-path[^}]*}/g, ''],
[/src:url\("patternfly-icons-fake-path\/pficon[^}]*/g, 'src:url("../base1/fonts/patternfly.woff") format("woff");'],
]
}),
]
}).catch(() => process.exit(1));