Updated
This commit is contained in:
parent
8e724b166a
commit
b5e92165c8
33 changed files with 82 additions and 223 deletions
|
|
@ -9,7 +9,7 @@ try {
|
|||
const config = toml.parse(fs.readFileSync("configs/config.site.toml", "utf8"));
|
||||
|
||||
if (fs.existsSync(dirPath)) {
|
||||
const inputSrc = "./src/assets/images/favicon.png";
|
||||
const inputSrc = "./src/images/favicon.png";
|
||||
const favicon = dirPath + "/favicon.png";
|
||||
const chrome192 = dirPath + "/android-chrome-192x192.png";
|
||||
const chrome512 = dirPath + "/android-chrome-512x512.png";
|
||||
|
|
|
|||
23
@dasig/scripts/node/optimizeBackground.ts
Normal file
23
@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`);
|
||||
}
|
||||
})();
|
||||
|
|
@ -26,14 +26,14 @@ import { hideBin } from "yargs/helpers";
|
|||
const avifOutputPath = `./@dasig/images/${name.toString().split(".").slice(0, -1).join(".")}.avif`;
|
||||
const webpOutputPath = `./@dasig/images/${name.toString().split(".").slice(0, -1).join(".")}.webp`;
|
||||
|
||||
const avifBuffer = await sharp(`./src/assets/images/${name}`)
|
||||
const avifBuffer = await sharp(`./src/images/${name}`)
|
||||
.avif({ quality: 60 })
|
||||
.resize(size)
|
||||
.toBuffer();
|
||||
await sharp(avifBuffer).toFile(avifOutputPath);
|
||||
consola.success(`${name} successfully optimized in Avif`);
|
||||
|
||||
const webpBuffer = await sharp(`./src/assets/images/${name}`)
|
||||
const webpBuffer = await sharp(`./src/images/${name}`)
|
||||
.webp({ quality: 75 })
|
||||
.resize(size)
|
||||
.toBuffer();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import { hideBin } from "yargs/helpers";
|
|||
try {
|
||||
const webpImage = "./@dasig/images/logo.webp";
|
||||
const avifImage = "./@dasig/images/logo.avif";
|
||||
const inputSrc = "./src/assets/images/logo.png";
|
||||
const inputSrc = "./src/images/logo.png";
|
||||
|
||||
const avifBuffer = await sharp(inputSrc)
|
||||
.avif({ quality: 60 })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue