From 4bd3849ccde073cc4c64e0ebfb1ec1b6d5a3ca00 Mon Sep 17 00:00:00 2001 From: Zack Tanner <1939140+ztanner@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:42:50 -0700 Subject: [PATCH] create-next-app: fix font file corruption when using import alias (#69806) There's code that uses `glob` to find all template files and replaces the default import alias with whatever is specified during CNA. This does so without excluding fonts, and so we're unintentionally corrupting these `woff` files. This wasn't a problem in previous versions because we didn't use `localFont` in the default template, just `Inter`. The files were technically still being corrupted it just never manifested unless you went to actually use them. This is a quick fix to introduce minimal changes but ideally in a follow-up we should figure out a better solution for replacing aliases, ie by using an allowlist rather than an exclude list. h/t to @lubieowoce for the thorough test cases Fixes #69748 --------- Co-authored-by: Janka Uryga --- packages/create-next-app/templates/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/create-next-app/templates/index.ts b/packages/create-next-app/templates/index.ts index c4976b2f1bde5..c3ebc78d30ffd 100644 --- a/packages/create-next-app/templates/index.ts +++ b/packages/create-next-app/templates/index.ts @@ -97,7 +97,16 @@ export const installTemplate = async ({ stats: false, // We don't want to modify compiler options in [ts/js]config.json // and none of the files in the .git folder - ignore: ["tsconfig.json", "jsconfig.json", ".git/**/*"], + // TODO: Refactor this to be an allowlist, rather than a denylist, + // to avoid corrupting files that weren't intended to be replaced + + ignore: [ + "tsconfig.json", + "jsconfig.json", + ".git/**/*", + "**/fonts/**", + "**/favicon.ico", + ], }); const writeSema = new Sema(8, { capacity: files.length }); await Promise.all(