-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
35 lines (35 loc) · 1.07 KB
/
build.js
File metadata and controls
35 lines (35 loc) · 1.07 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
const path = require("path");
const AdmZip = require("adm-zip");
const { version } = require('./apps/manifest.json');
const { name } = require('./apps/manifest.json');
const MAIN_JS_PATH = path.resolve(__dirname, "./apps");
const isRelease = process.argv.includes("--release");
const EXTENSION_NAME = `${name}${version}.zip`;
const ARTIFACT_PATH = path.resolve(__dirname, `./release/${EXTENSION_NAME}`);
const createZip = () => {
const zip = new AdmZip();
zip.addLocalFolder(MAIN_JS_PATH);
zip.writeZip(isRelease ? ARTIFACT_PATH : path.relative(__dirname, `./dist/${EXTENSION_NAME}`));
console.log(new Date(), "Zip created");
}
require("esbuild")
.build({
entryPoints: ["src/index.js", "src/controller/options.ts"],
platform: "browser",
treeShaking: false,
outdir: `${MAIN_JS_PATH}/dist`,
minify: true,
sourcemap: isRelease ? false : 'inline',
bundle: true,
watch: !isRelease,
drop: isRelease ? ['console'] : []
})
.then(() => {
if(isRelease) {
createZip();
}
})
.catch((err) => {
console.error(err);
process.exit(1);
});