diff --git a/packages/cli/src/utils/generate.test.ts b/packages/cli/src/utils/generate.test.ts index 116c53bd1f..2c36b25703 100644 --- a/packages/cli/src/utils/generate.test.ts +++ b/packages/cli/src/utils/generate.test.ts @@ -194,6 +194,21 @@ describe('isPublicFileAllowed', () => { expect(isPublicFileAllowed('/public/fonts/inter.eot', false)).toBe(true) }) + it('copies image assets used for favicons and social previews', () => { + expect(isPublicFileAllowed('/public/favicon.png', false)).toBe(true) + expect(isPublicFileAllowed('/public/apple-touch-icon.jpg', false)).toBe( + true + ) + expect(isPublicFileAllowed('/public/og-image.jpeg', false)).toBe(true) + expect(isPublicFileAllowed('/public/hero.webp', false)).toBe(true) + expect(isPublicFileAllowed('/public/loading.gif', false)).toBe(true) + expect(isPublicFileAllowed('/public/banner.avif', false)).toBe(true) + }) + + it('copies the PWA web app manifest', () => { + expect(isPublicFileAllowed('/public/site.webmanifest', false)).toBe(true) + }) + it('still copies the previously supported extensions', () => { expect(isPublicFileAllowed('/public/manifest.json', false)).toBe(true) expect(isPublicFileAllowed('/public/robots.txt', false)).toBe(true) @@ -205,6 +220,7 @@ describe('isPublicFileAllowed', () => { it('matches the extension case-insensitively', () => { expect(isPublicFileAllowed('/public/fonts/Inter.WOFF2', false)).toBe(true) expect(isPublicFileAllowed('/public/LOGO.SVG', false)).toBe(true) + expect(isPublicFileAllowed('/public/Favicon.PNG', false)).toBe(true) }) it('rejects files whose extension is not allowed', () => { diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 78ba40c7ea..b622a214a3 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -234,7 +234,9 @@ function copyCoreFiles(basePath: string) { // File extensions allowed to be copied from the store's `public/` folder into // the build. Fonts are included so stores can self-host them (GDPR / CWV) -// instead of relying on external CDNs. +// instead of relying on external CDNs. Raster and modern image formats are +// included so favicons, apple-touch icons and social preview images survive +// the build, along with `.webmanifest` for PWA metadata. export const PUBLIC_FILES_ALLOWED_EXTENSIONS = [ '.json', '.txt', @@ -246,6 +248,13 @@ export const PUBLIC_FILES_ALLOWED_EXTENSIONS = [ '.ttf', '.otf', '.eot', + '.png', + '.jpg', + '.jpeg', + '.webp', + '.gif', + '.avif', + '.webmanifest', ] /**