-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
45 lines (39 loc) · 1.16 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
import { promises as fs } from "fs";
import * as esbuild from "esbuild";
import * as path from "path";
async function copyFilesToDirectory(fileList, targetDirectory) {
try {
await fs.rm(targetDirectory, { recursive: true });
await fs.mkdir(targetDirectory, { recursive: true });
const copyPromises = fileList.map(async (file) => {
const sourcePath = path.resolve(file);
const targetPath = path.join(targetDirectory, path.basename(file));
await fs.copyFile(sourcePath, targetPath);
console.log(`Copied file '${file}' to '${targetPath}'`);
});
await Promise.all(copyPromises);
} catch (error) {
console.error(`Error copying files: ${error}`);
}
}
const filesToCopy = [
"manifest.json",
"background.js",
"background.html",
"images/icon-16px.png",
"images/icon-32px.png",
"images/icon-64px.png",
];
const targetDirectory = "./build";
await Promise.all([
copyFilesToDirectory(filesToCopy, targetDirectory),
esbuild
.build({
entryPoints: ["src/content-script.js"],
bundle: true,
outfile: "./build/content-script.js",
})
.then(() => {
console.log("Esbuild successful");
}),
]);