Skip to content

Commit

Permalink
Add favicon for development (#162)
Browse files Browse the repository at this point in the history
* Add campfire.svg icon to /web/main folder, change favicon for localhost and build to separate dev environment with prodution. Now for production we use icon.svg in index.html entry point and for development we use campfire.svg in index.html

* revert changes in style section

* return deleted .ico link in index.html

* add STAGING variable for github action workflow to set STAGING variable when pnpm build is running

* add comment at vite.config.ts

* swap enforce and name fields in vite.config.ts

* comments was removed from vite.config.ts

* move campfire.svg from web/main to web/public, rewrite transformIndexHtml function in vite.config.ts

* favicon campfire.svg was moved web/public folder

---------

Co-authored-by: daniil <Daniil Makhov>
  • Loading branch information
Edward-Leopold authored Apr 14, 2024
1 parent 4c9a46b commit 9bfbf99
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/preview-prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
run: pnpm install --no-frozen-lockfile --ignore-scripts
- name: Build assets
run: cd web && pnpm build
env:
STAGING: 1
- name: Save PR number
run: echo "${{ github.event.pull_request.number }}" > ./preview-id
- name: Save web assets for deploy
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
run: pnpm run -r --include-workspace-root '/^test:(?!markdown\b)/'
env:
FORCE_COLOR: 1
STAGING: 1
- name: Upload web assets
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions web/public/campfire.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ export default defineConfig(() => ({
svelte(),
nodeResolve({
extensions: ['.js', '.ts']
})
}),
{
enforce: 'pre',
name: 'html-transform',
transformIndexHtml(html) {
if (process.env.NODE_ENV === 'development' || process.env.STAGING) {
return html
.replace(
'<link rel="icon" href="/favicon.ico" sizes="32x32" />',
''
)
.replace(
/<link rel="icon" href="[^"]+" type="image\/svg\+xml" \/>/,
'<link rel="icon" href="/campfire.svg" type="image/svg+xml" />'
)
} else {
return html
}
}
}
]
}))

0 comments on commit 9bfbf99

Please sign in to comment.