-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2319 from blockscout/fe-2287
Favicon generator: replace realfavicon with favicons package
- Loading branch information
Showing
32 changed files
with
1,296 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/output | ||
config.json | ||
response.json | ||
favicon_package** | ||
/node_modules | ||
/public | ||
.env | ||
/output |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* eslint-disable no-console */ | ||
const { favicons } = require('favicons'); | ||
const fs = require('fs/promises'); | ||
const path = require('path'); | ||
|
||
generateFavicons(); | ||
|
||
async function generateFavicons() { | ||
console.log('Generating favicons...'); | ||
const masterUrl = process.env.MASTER_URL; | ||
try { | ||
if (!masterUrl) { | ||
throw new Error('FAVICON_MASTER_URL or NEXT_PUBLIC_NETWORK_ICON must be set'); | ||
} | ||
|
||
const fetch = await import('node-fetch'); | ||
const response = await fetch.default(masterUrl); | ||
const buffer = await response.arrayBuffer(); | ||
const source = Buffer.from(buffer); | ||
|
||
const configuration = { | ||
path: '/output', | ||
appName: 'Blockscout', | ||
icons: { | ||
android: true, | ||
appleIcon: { | ||
background: 'transparent', | ||
}, | ||
appleStartup: false, | ||
favicons: true, | ||
windows: false, | ||
yandex: false, | ||
}, | ||
}; | ||
|
||
try { | ||
const result = await favicons(source, configuration); | ||
|
||
const outputDir = path.resolve(process.cwd(), 'output'); | ||
await fs.mkdir(outputDir, { recursive: true }); | ||
|
||
for (const image of result.images) { | ||
// keep only necessary files | ||
if (image.name === 'apple-touch-icon-180x180.png' || image.name === 'android-chrome-192x192.png' || | ||
(!image.name.startsWith('apple-touch-icon') && !image.name.startsWith('android-chrome')) | ||
) { | ||
await fs.writeFile(path.join(outputDir, image.name), image.contents); | ||
} | ||
|
||
// copy android-chrome-192x192.png to logo-icon.png for marketing purposes | ||
if (image.name === 'android-chrome-192x192.png') { | ||
await fs.writeFile(path.join(outputDir, 'logo-icon.png'), image.contents); | ||
} | ||
} | ||
|
||
for (const file of result.files) { | ||
if (file.name !== 'manifest.webmanifest') { | ||
await fs.writeFile(path.join(outputDir, file.name), file.contents); | ||
} | ||
} | ||
|
||
console.log('Favicons generated successfully!'); | ||
} catch (faviconError) { | ||
console.warn('Error generating favicons:', faviconError); | ||
} | ||
} catch (error) { | ||
console.error('Error in favicon generation process:', error); | ||
process.exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "favicon-generator", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"description": "", | ||
"dependencies": { | ||
"favicons": "^7.2.0", | ||
"ts-loader": "^9.4.4", | ||
"webpack": "^5.88.2", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
"devDependencies": { | ||
"dotenv-cli": "^7.4.2", | ||
"node-loader": "^2.0.0", | ||
"tsconfig-paths-webpack-plugin": "^4.1.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.