-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (29 loc) · 738 Bytes
/
app.js
File metadata and controls
35 lines (29 loc) · 738 Bytes
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
import imagemin from "imagemin";
import imageminWebp from "imagemin-webp";
import fs from "fs/promises";
const webpConverter = async () => {
try {
await imagemin(["images/*.{jpg,png}"], {
destination: "build/images",
plugins: [imageminWebp({ quality: 50 })],
});
console.log("Images optimized");
console.log("완료!");
} catch (e) {
console.log(e);
}
};
// webpConverter();
const getFileNames = async (path) => {
try {
const files = await fs.readdir(path);
const fileNamesWithoutWebp = files.map(
(fileName) => fileName.split(".")[0]
);
console.log(fileNamesWithoutWebp);
return files;
} catch (err) {
console.log(err);
}
};
getFileNames("./build/images");