Skip to content

Commit

Permalink
add support for favicon in app dir (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
baked-dev authored Mar 16, 2023
1 parent 4e6208b commit 5158746
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
10 changes: 0 additions & 10 deletions examples/basic-js/app/[locale]/head.jsx

This file was deleted.

File renamed without changes.
Binary file added examples/basic/app/favicon.ico
Binary file not shown.
11 changes: 10 additions & 1 deletion packages/codegen/src/build/collect-public.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import _glob from "glob";
import { promisify } from "util";
const glob = promisify(_glob);
import fse from "fs-extra";
const { stat } = fse;

/**
* @returns A string array of all the files in the public folder
*/
const collectPublicFiles = async () => {
return (await glob("public/**/*")).map((path) => path.slice(6));
const publicFiles = (await glob("public/**/*")).map((path) => path.slice(6));
try {
if ((await stat("app/favicon.ico")).isFile())
publicFiles.push("/favicon.ico");
} catch {
/* empty */
}
return publicFiles;
};

export default collectPublicFiles;
1 change: 1 addition & 0 deletions packages/codegen/src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const watchConfig = {
"app/**/route.{ts,js}",
"app/**/redirect.{ts,js}",
"public/**/*",
"app/favicon.ico",
],
"add unlink change": [
"app/**/forward.dynamic.{ts,js}",
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/router/ejected/head/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ${renderHooksImport(hooks)}
${renderDynamicImports(imports)}
const publicFiles = new Set<string>([${publicFiles
const publicFiles = new Set<string>([${Array.from(new Set(publicFiles))
.map((publicFile) => `"${publicFile}"`)
.join(", ")}]);
`.trim();
Expand Down

0 comments on commit 5158746

Please sign in to comment.