Skip to content

Commit

Permalink
fix: custom favicons for each domain
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Feb 22, 2024
1 parent ce0ca7f commit f470f53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 12 additions & 4 deletions packages/vite-plugins/lib/favicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ const { log, HELPERS } = require('@rm/logger')
*/
const faviconPlugin = (isDevelopment) => {
try {
const favicon = fs.existsSync(
resolve(__dirname, '../../../public/favicon/favicon.ico'),
const basePath = '../../../public/favicon'
const fallback = resolve(__dirname, `${basePath}/fallback.ico`)
const singleDomainPath = resolve(`${basePath}/favicon.ico`)
const multiDomainPath = resolve(
`${basePath}/${
process.env.NODE_CONFIG_ENV ? `-${process.env.NODE_CONFIG_ENV}` : ''
}.ico`,
)
? resolve(__dirname, '../../../public/favicon/favicon.ico')
: resolve(__dirname, '../../../public/favicon/fallback.ico')
const favicon = fs.existsSync(multiDomainPath)
? multiDomainPath
: fs.existsSync(singleDomainPath)
? singleDomainPath
: fallback
return {
name: 'vite-plugin-favicon',
generateBundle() {
Expand Down
3 changes: 1 addition & 2 deletions server/src/configs/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
"bearerToken": "KOJI_SECRET"
}
},
"multiDomains": [],
"map": {
"general": {
"title": "ReactMap",
Expand Down Expand Up @@ -1021,4 +1020,4 @@
"tracesSampleRate": 0.1
}
}
}
}

0 comments on commit f470f53

Please sign in to comment.