Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imgix plugin #849

Merged
merged 4 commits into from
Jan 14, 2021
Merged

Imgix plugin #849

merged 4 commits into from
Jan 14, 2021

Conversation

mariusandra
Copy link
Collaborator

Once #848 is merged, this can be added on top.

This adds a custom gatsby plugin that rewrites local images to use imgix in production builds (disabled for branch and deploy previews).

It finds every local image, gets its dimensions and then generates a srcSet attribute with matching imgix urls.

For an image like:
https://posthog.com/static/33fac05700a7fd86bd306b4c829493e7/d9ed5/toolbar-landing-page.png

We will generate urls like:
https://posthog.imgix.net/static/33fac05700a7fd86bd306b4c829493e7/d9ed5/toolbar-landing-page.png?w=500
... with different values for w.

PR #848 needs to be merged first, as without the gatsby-remark-images plugin, the image URLs will be different, more like /static/feature-flags-1e8c20eefc3f0f8e8e72c0ce8101afcf.png instead of /static/hash1/hash2/feature-flags.png. If the new images are uploaded to production, we can test locally that this works with enabled: true before finally merging this.

@yakkomajuri
Copy link
Contributor

Quick look and images are not showing on the preview site - without much digging I wonder if that has to do with the context? If that's the case it'd actually be important to have the images in dev too

@mariusandra
Copy link
Collaborator Author

whoops, forgot some quotes

@mariusandra
Copy link
Collaborator Author

I think there might be a caching issue with the deploy preview now. :/

@yakkomajuri
Copy link
Contributor

@mariusandra still no images :(

@yakkomajuri
Copy link
Contributor

Oh if it's a cache issue that's easy, I'll retrigger a deploy without cache

@yakkomajuri
Copy link
Contributor

Done - let's see

@yakkomajuri
Copy link
Contributor

Yup that's working now, and the great news is, for a cacheless build:

8:21:42 AM: info Done building in 154.53258247 sec

@yakkomajuri yakkomajuri merged commit beff03c into master Jan 14, 2021
@yakkomajuri yakkomajuri deleted the imgix-plugin branch January 14, 2021 11:24
@yakkomajuri yakkomajuri mentioned this pull request Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants