Add option to disable downloading of images when using the `gatsby-source-shopify` plugin.
See original GitHub issueSummary
I’m working on rebuilding an existing Shopify site as a Gatsby site using the gatsby-source-shopify
plugin. It has ~600x items, and my internet connection isn’t particularly good, so it can take a very long time for the site the build (even in develop mode). Sometimes the build will fail completely. If sharp tries to transform any of the images it takes even longer and is even less stable.
I think it might be a good idea to add an option to disable downloading the images, as we can still serve the images from Shopify’s CDN. The Shopify CDN will let you resize images using the URL, so the performance is still pretty good. Here is a page with some info on doing this: https://www.shopify.com/partners/blog/img-url-filter
Basic example
plugins: [
{
resolve: `gatsby-source-shopify`,
options: {
shopName: process.env.SHOPIFY_SHOP_NAME,
accessToken: accessToken: process.env.SHOPIFY_ACCESS_TOKEN,
// Whether or not images should be downloaded locally so that they can be
// transformed by sharp. You might want to disable this for stores with a
// lot of products
// Defaults to true
downloadImage: false,
},
},
];
Motivation
Adding this option will make it much easier for people to use this plugin if they have poor internet connections, less powerful computers, or are using it to connect to a store with a large number of images to download.
I plan to attempt to add this myself (along with the help of my friend @mrhut10), but I’ve never written/worked on a Gatsby plugin before, and have limited knowledge of GraphQL outside of using it within Gatsby.
I also wanted to make sure it sounded like a good idea first, and that I’m not overlooking anything before doing the work and submitting a PR only to have it rejected.
If this goes well, I want to also work on a companion plugin to use the images from the Shopify CDN in gatsby-image
in much the same way as
gatsby-transformer-cloudinary
I’m not sure if this is possible since we need a base64 image as well, but I’ll open a seperate issue for that once I get some feedback on this issue.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:15 (5 by maintainers)
Top GitHub Comments
Looks like you need to yeah tag “not stale” to prevent it automatically being closed by there bots
Yeah from how @lukebennett88 description to me privately if you’ve got 500+ products with 5 images on each products then that’s 2500 images to download them if you try to use them it will then do all the required transformations. This is huge unneeded downloads, storage and processing when Shopify provides a CDN.
The Gatsby-source-sanity plugin I noticed uses the sanity CDN (or optionally cloudinary)
Hope that helps.
@lukebennett88 and I would loved to help make an attempt at a pr to achieve. But certainly open to help.