Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Can't resolve 'next/font/local/target.css'" #29

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ next-env.d.ts

# Sentry Config File
.env.sentry-build-plugin

# prepare fonts programmatically
app/fonts/index.ts
File renamed without changes.
Empty file removed app/fonts/Rosart-Medium.woff2
Empty file.
Empty file removed app/fonts/Rosart-Regular.woff2
Empty file.
Empty file.
Empty file removed app/fonts/Rosart-SemiBold.woff2
Empty file.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"version": "0.1.0",
"private": true,
"scripts": {
"predev": "node prepare-font.js",
"dev": "SENTRY_SUPPRESS_TURBOPACK_WARNING=1 next dev --turbo",
"prebuild": "node download-assets.js",
"prebuild": "node prepare-font.js",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand Down
4 changes: 3 additions & 1 deletion download-assets.js → prepare-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const downloadFile = async (url, destination) => {
url: `${BLOB_URL}/fonts/${fileName}.woff2`,
destination: `./app/fonts/${fileName}.woff2`,
}));
fs.copyFile("./vendor/fonts/rosert.ts", "./app/fonts/index.ts");

for (const file of filesToDownload) {
try {
Expand All @@ -45,6 +46,7 @@ const downloadFile = async (url, destination) => {
}
}
} else {
console.log("Skipping download in non-production environment");
fs.copyFile("./vendor/fonts/alternative.ts", "./app/fonts/index.ts");
console.log("Using an alternative font file in development mode.");
}
})();
8 changes: 8 additions & 0 deletions vendor/fonts/alternative.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Roboto_Serif } from "next/font/google";
/**
* Since the Rosart font is a proprietary font, use an alternative font during OSS development.
*/
export const rosart = Roboto_Serif({
variable: "--font-rosart",
subsets: ["latin"],
});
File renamed without changes.