From 11737be41d4ce0516aeb54452097d26a509720b9 Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Wed, 10 Nov 2021 16:10:09 +0900 Subject: [PATCH 1/5] refactor: move favicon to public directory --- packages/dev/index.html | 2 +- packages/dev/{src => public}/favicon.svg | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/dev/{src => public}/favicon.svg (100%) diff --git a/packages/dev/index.html b/packages/dev/index.html index 8d6afb03d8..43fb95cf09 100644 --- a/packages/dev/index.html +++ b/packages/dev/index.html @@ -2,7 +2,7 @@ - + Hydrogen App diff --git a/packages/dev/src/favicon.svg b/packages/dev/public/favicon.svg similarity index 100% rename from packages/dev/src/favicon.svg rename to packages/dev/public/favicon.svg From ccc44c8e805ae875ca999f2812b0255da6035aa1 Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Wed, 10 Nov 2021 16:11:07 +0900 Subject: [PATCH 2/5] fix: run Hydrogen middleware after Vite handles static assets --- .../vite-plugin-hydrogen-middleware.ts | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/hydrogen/src/framework/plugins/vite-plugin-hydrogen-middleware.ts b/packages/hydrogen/src/framework/plugins/vite-plugin-hydrogen-middleware.ts index 6228575a37..64bdc433ae 100644 --- a/packages/hydrogen/src/framework/plugins/vite-plugin-hydrogen-middleware.ts +++ b/packages/hydrogen/src/framework/plugins/vite-plugin-hydrogen-middleware.ts @@ -25,19 +25,20 @@ export default ( return await server.transformIndexHtml(url, indexHtml); } - server.middlewares.use( - hydrogenMiddleware({ - dev: true, - shopifyConfig, - indexTemplate: getIndexTemplate, - getServerEntrypoint: async () => - await server.ssrLoadModule(resolve('./src/entry-server')), - devServer: server, - cache: pluginOptions?.devCache - ? (new InMemoryCache() as unknown as Cache) - : undefined, - }) - ); + return () => + server.middlewares.use( + hydrogenMiddleware({ + dev: true, + shopifyConfig, + indexTemplate: getIndexTemplate, + getServerEntrypoint: async () => + await server.ssrLoadModule(resolve('./src/entry-server')), + devServer: server, + cache: pluginOptions?.devCache + ? (new InMemoryCache() as unknown as Cache) + : undefined, + }) + ); }, } as Plugin; }; From c8e601d374272dd213c42be6165f322ce7966499 Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Wed, 10 Nov 2021 16:13:47 +0900 Subject: [PATCH 3/5] chore: update changelog --- packages/hydrogen/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/hydrogen/CHANGELOG.md b/packages/hydrogen/CHANGELOG.md index d8c268222e..e8e2e0fa41 100644 --- a/packages/hydrogen/CHANGELOG.md +++ b/packages/hydrogen/CHANGELOG.md @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). - +## Unreleased + +- fix: let Vite handle public assets in development ## 0.6.3 - 2021-11-10 From 451971980d8e82dd48a41615dae511f3e82795f9 Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Thu, 11 Nov 2021 12:59:11 +0900 Subject: [PATCH 4/5] refactor: move favicon in all projects to public directories --- .../commands/create/app/templates/index-html.ts | 2 +- .../server-components-worker/index.html | 2 +- .../{src => public}/favicon.svg | 0 packages/playground/server-components/index.html | 2 +- .../server-components/public/favicon.svg | 15 +++++++++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) rename packages/playground/server-components-worker/{src => public}/favicon.svg (100%) create mode 100644 packages/playground/server-components/public/favicon.svg diff --git a/packages/cli/src/commands/create/app/templates/index-html.ts b/packages/cli/src/commands/create/app/templates/index-html.ts index 706bd36696..d0063a6851 100644 --- a/packages/cli/src/commands/create/app/templates/index-html.ts +++ b/packages/cli/src/commands/create/app/templates/index-html.ts @@ -7,7 +7,7 @@ export default function ({ifFeature}: TemplateOptions) { - + ${ifFeature( diff --git a/packages/playground/server-components-worker/index.html b/packages/playground/server-components-worker/index.html index 308dd818b7..af59b82557 100644 --- a/packages/playground/server-components-worker/index.html +++ b/packages/playground/server-components-worker/index.html @@ -2,7 +2,7 @@ - + Hydrogen App diff --git a/packages/playground/server-components-worker/src/favicon.svg b/packages/playground/server-components-worker/public/favicon.svg similarity index 100% rename from packages/playground/server-components-worker/src/favicon.svg rename to packages/playground/server-components-worker/public/favicon.svg diff --git a/packages/playground/server-components/index.html b/packages/playground/server-components/index.html index 308dd818b7..af59b82557 100644 --- a/packages/playground/server-components/index.html +++ b/packages/playground/server-components/index.html @@ -2,7 +2,7 @@ - + Hydrogen App diff --git a/packages/playground/server-components/public/favicon.svg b/packages/playground/server-components/public/favicon.svg new file mode 100644 index 0000000000..de4aeddc12 --- /dev/null +++ b/packages/playground/server-components/public/favicon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + From 996b71f639e1d188bce45896477a6d12aae2ce49 Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Thu, 11 Nov 2021 13:19:27 +0900 Subject: [PATCH 5/5] fix: remove favicon.ico check --- packages/hydrogen/src/framework/middleware.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/hydrogen/src/framework/middleware.ts b/packages/hydrogen/src/framework/middleware.ts index 5261aa5373..2f25050f4a 100644 --- a/packages/hydrogen/src/framework/middleware.ts +++ b/packages/hydrogen/src/framework/middleware.ts @@ -141,9 +141,8 @@ function shouldInterceptRequest( isReactHydrationRequest: boolean ) { return ( - (/text\/html|application\/hydrogen/.test(request.headers['accept'] ?? '') || - isReactHydrationRequest) && - request.url !== '/favicon.ico' + /text\/html|application\/hydrogen/.test(request.headers['accept'] ?? '') || + isReactHydrationRequest ); }