Updated
This commit is contained in:
parent
bbfa0b38ee
commit
fe90f5988a
31 changed files with 613 additions and 50 deletions
23
frontend/src/@dasig/scripts/node/generateFavicon.js
Normal file
23
frontend/src/@dasig/scripts/node/generateFavicon.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { consola } from 'consola';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import sharp from 'sharp';
|
||||
|
||||
try {
|
||||
const dirPath = path.resolve('./public')
|
||||
|
||||
if (fs.existsSync(dirPath)) {
|
||||
const inputSrc = './src/images/favicon.png'
|
||||
const favicon = dirPath + '/favicon.png'
|
||||
const faviconBuffer = await sharp(inputSrc).png({ quality: 90 }).resize(48).toBuffer()
|
||||
await sharp(faviconBuffer).toFile(favicon)
|
||||
consola.success('Favicon generated successfully')
|
||||
} else {
|
||||
consola.error('Directory does not exist:', dirPath)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
if (error.message.includes('missing')) {
|
||||
consola.error('Source favicon does not exist')
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue