Added script to generate favicon
This commit is contained in:
parent
66697ca2d3
commit
da171b15ea
1 changed files with 21 additions and 0 deletions
21
src/utils/scripts/generateFavicon.js
Normal file
21
src/utils/scripts/generateFavicon.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import sharp from 'sharp'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { consola } from 'consola'
|
||||
;(async () => {
|
||||
try {
|
||||
const dirPath = path.resolve('../../../public')
|
||||
|
||||
if (fs.existsSync(dirPath)) {
|
||||
const inputSrc = '../../assets/images/logo.png'
|
||||
const favicon = dirPath + '/favicon.png'
|
||||
const faviconBuffer = await sharp(inputSrc).png({ quality: 90 }).resize(50).toBuffer()
|
||||
await sharp(faviconBuffer).toFile(favicon)
|
||||
consola.success('Favicon generated successfully')
|
||||
} else {
|
||||
consola.error('Directory does not exist:', dirPath)
|
||||
}
|
||||
} catch (error) {
|
||||
consola.error('Error generating favicon:', error)
|
||||
}
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue