Skip to content

Commit a344b34

Browse files
authored
refactor: generate only asset name for published sites (#4947)
We don't really need anything from asset object on published sites except the name to resolve the file. Here got rid from Asset objects for favicon, fonts and backgrounds. This should reduce client bundle where a lot of assets are used.
1 parent 0f3a308 commit a344b34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+186
-377
lines changed

fixtures/react-router-docker/app/__generated__/[another-page]._index.tsx

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/react-router-docker/app/__generated__/_index.tsx

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/react-router-docker/app/routes/[another-page]._index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const links: LinksFunction = () => {
150150
result.push({
151151
rel: "icon",
152152
href: imageLoader({
153-
src: `${assetBaseUrl}${favIconAsset.name}`,
153+
src: `${assetBaseUrl}${favIconAsset}`,
154154
// width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
155155
width: 144,
156156
height: 144,
@@ -165,7 +165,7 @@ export const links: LinksFunction = () => {
165165
for (const asset of pageFontAssets) {
166166
result.push({
167167
rel: "preload",
168-
href: `${assetBaseUrl}${asset.name}`,
168+
href: `${assetBaseUrl}${asset}`,
169169
as: "font",
170170
crossOrigin: "anonymous",
171171
});
@@ -174,7 +174,7 @@ export const links: LinksFunction = () => {
174174
for (const backgroundImageAsset of pageBackgroundImageAssets) {
175175
result.push({
176176
rel: "preload",
177-
href: `${assetBaseUrl}${backgroundImageAsset.name}`,
177+
href: `${assetBaseUrl}${backgroundImageAsset}`,
178178
as: "image",
179179
});
180180
}

fixtures/react-router-docker/app/routes/_index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const links: LinksFunction = () => {
150150
result.push({
151151
rel: "icon",
152152
href: imageLoader({
153-
src: `${assetBaseUrl}${favIconAsset.name}`,
153+
src: `${assetBaseUrl}${favIconAsset}`,
154154
// width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
155155
width: 144,
156156
height: 144,
@@ -165,7 +165,7 @@ export const links: LinksFunction = () => {
165165
for (const asset of pageFontAssets) {
166166
result.push({
167167
rel: "preload",
168-
href: `${assetBaseUrl}${asset.name}`,
168+
href: `${assetBaseUrl}${asset}`,
169169
as: "font",
170170
crossOrigin: "anonymous",
171171
});
@@ -174,7 +174,7 @@ export const links: LinksFunction = () => {
174174
for (const backgroundImageAsset of pageBackgroundImageAssets) {
175175
result.push({
176176
rel: "preload",
177-
href: `${assetBaseUrl}${backgroundImageAsset.name}`,
177+
href: `${assetBaseUrl}${backgroundImageAsset}`,
178178
as: "image",
179179
});
180180
}

fixtures/react-router-netlify/app/__generated__/[another-page]._index.tsx

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/react-router-netlify/app/__generated__/_index.tsx

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/react-router-netlify/app/routes/[another-page]._index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const links: LinksFunction = () => {
150150
result.push({
151151
rel: "icon",
152152
href: imageLoader({
153-
src: `${assetBaseUrl}${favIconAsset.name}`,
153+
src: `${assetBaseUrl}${favIconAsset}`,
154154
// width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
155155
width: 144,
156156
height: 144,
@@ -165,7 +165,7 @@ export const links: LinksFunction = () => {
165165
for (const asset of pageFontAssets) {
166166
result.push({
167167
rel: "preload",
168-
href: `${assetBaseUrl}${asset.name}`,
168+
href: `${assetBaseUrl}${asset}`,
169169
as: "font",
170170
crossOrigin: "anonymous",
171171
});
@@ -174,7 +174,7 @@ export const links: LinksFunction = () => {
174174
for (const backgroundImageAsset of pageBackgroundImageAssets) {
175175
result.push({
176176
rel: "preload",
177-
href: `${assetBaseUrl}${backgroundImageAsset.name}`,
177+
href: `${assetBaseUrl}${backgroundImageAsset}`,
178178
as: "image",
179179
});
180180
}

fixtures/react-router-netlify/app/routes/_index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const links: LinksFunction = () => {
150150
result.push({
151151
rel: "icon",
152152
href: imageLoader({
153-
src: `${assetBaseUrl}${favIconAsset.name}`,
153+
src: `${assetBaseUrl}${favIconAsset}`,
154154
// width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
155155
width: 144,
156156
height: 144,
@@ -165,7 +165,7 @@ export const links: LinksFunction = () => {
165165
for (const asset of pageFontAssets) {
166166
result.push({
167167
rel: "preload",
168-
href: `${assetBaseUrl}${asset.name}`,
168+
href: `${assetBaseUrl}${asset}`,
169169
as: "font",
170170
crossOrigin: "anonymous",
171171
});
@@ -174,7 +174,7 @@ export const links: LinksFunction = () => {
174174
for (const backgroundImageAsset of pageBackgroundImageAssets) {
175175
result.push({
176176
rel: "preload",
177-
href: `${assetBaseUrl}${backgroundImageAsset.name}`,
177+
href: `${assetBaseUrl}${backgroundImageAsset}`,
178178
as: "image",
179179
});
180180
}

fixtures/react-router-vercel/app/__generated__/[another-page]._index.tsx

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/react-router-vercel/app/__generated__/_index.tsx

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)