Skip to content
Open
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
16 changes: 16 additions & 0 deletions packages/cli/src/utils/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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', () => {
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/src/utils/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -246,6 +248,13 @@ export const PUBLIC_FILES_ALLOWED_EXTENSIONS = [
'.ttf',
'.otf',
'.eot',
'.png',
'.jpg',
'.jpeg',
'.webp',
'.gif',
'.avif',
'.webmanifest',
]

/**
Expand Down