Updated
This commit is contained in:
parent
cde344cb59
commit
b8a0d0179e
12 changed files with 70 additions and 44 deletions
|
|
@ -11,7 +11,7 @@ import * as toml from 'toml'
|
|||
try {
|
||||
const dirPath = path.resolve("./public");
|
||||
const config = toml.parse(fs.readFileSync("configs/config.site.toml", "utf8"));
|
||||
|
||||
|
||||
if (fs.existsSync(dirPath)) {
|
||||
const inputSrc = "./src/images/favicon.png";
|
||||
const favicon = dirPath + "/favicon.png";
|
||||
|
|
|
|||
23
frontend/@dasig/scripts/node/optimizeBackground.ts
Normal file
23
frontend/@dasig/scripts/node/optimizeBackground.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { consola } from "consola";
|
||||
import sharp from "sharp";
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const inputSrc = 'src/images/background.png'
|
||||
const webpOutput = "./@dasig/images/background.webp"
|
||||
const avifOutput = "./@dasig/images/background.avif"
|
||||
|
||||
const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(1920).toBuffer()
|
||||
await sharp(avifBuffer).toFile(avifOutput)
|
||||
consola.success('Background successfully optimized in Avif');
|
||||
|
||||
const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(1920).toBuffer()
|
||||
await sharp(webpBuffer).toFile(webpOutput)
|
||||
consola.success('Background successfully optimized in Webp');
|
||||
|
||||
} catch (error: any) {
|
||||
consola.error("Error optimizing background:", error);
|
||||
if (error.message.includes("missing"))
|
||||
consola.error(`${name} could not be found on image folder`);
|
||||
}
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue