Skip to content

Commit

Permalink
refactor: static files
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Mar 8, 2024
1 parent 290ddbc commit 4871ff2
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 46 deletions.
64 changes: 24 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/dev/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// if this changes, make sure vite.config.ts is updated as well
export const staticPath = '/dev/static'
1 change: 1 addition & 0 deletions src/dev/entry-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render } from 'hono/jsx/dom'
import { App } from './App.js'
import { Provider, dataId } from './Context.js'

import '@fontsource-variable/inter'
import './styles.css'

const element = document.getElementById(dataId)
Expand Down
2 changes: 0 additions & 2 deletions src/dev/entry-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export function EntryServer(props: EntryServer) {
)}

{/* TODO: Load from file system */}
<link rel="preconnect" href="https://rsms.me/" />
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
<link rel="icon" href="https://frog.fm/icon.png" type="image/png" />
</head>
<body>
Expand Down
6 changes: 5 additions & 1 deletion src/dev/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ export async function routes<
serveStatic({
manifest,
root,
rewriteRequestPath: (path) => path.replace(`${staticPath}/`, '/'),
rewriteRequestPath(path) {
// fonts loaded from mirrored directory to `staticPath`
if (path.endsWith('.woff2')) return path
return path.replace(`${staticPath}/`, '/')
},
}),
)
else console.warn('No static file handler found for environment')
Expand Down
2 changes: 1 addition & 1 deletion src/dev/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@
}

@supports (font-variation-settings: normal) {
:root { font-family: InterVariable, arial, sans-serif; }
:root { font-family: 'Inter Variable', arial, sans-serif; }
}

*,
Expand Down
6 changes: 5 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"dependencies": {
"@bufbuild/protobuf": "^1.7.2",
"@farcaster/core": "^0.13.7",
"@fontsource-variable/inter": "^5.0.17",
"@hono/vite-dev-server": "0.7.0",
"@ngrok/ngrok": "^1.1.0",
"@noble/curves": "^1.3.0",
Expand All @@ -86,7 +87,10 @@
"license": "MIT",
"homepage": "https://frog.fm",
"repository": "wevm/frog",
"authors": ["awkweb.eth", "jxom.eth"],
"authors": [
"awkweb.eth",
"jxom.eth"
],
"funding": [
{
"type": "github",
Expand Down
6 changes: 5 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export default defineConfig({
dir: 'src/_lib/dev/static',
entryFileNames: 'entry-client.js',
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name].[ext]',
assetFileNames(assetInfo) {
if (assetInfo.name?.endsWith('.woff2'))
return 'dev/static/assets/[name].[ext]'
return 'assets/[name].[ext]'
},
},
},
target: 'esnext',
Expand Down

0 comments on commit 4871ff2

Please sign in to comment.