Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Asset download during nextjs export #10147

Closed
sandys opened this issue Jan 18, 2020 · 10 comments
Closed

Asset download during nextjs export #10147

sandys opened this issue Jan 18, 2020 · 10 comments

Comments

@sandys
Copy link

sandys commented Jan 18, 2020

Feature request

A related conversation to this feature happened here #9524 (comment)

if i use a headless CMS (even wordpress or graphcms or whatever), the asset url is used in the static html.

There are two preferences here - that asset links be used as such.
But more likely - download the asset, build the html (link to it locally) and then layer a CDN in front. This is the far more acceptable practice.

This also ties in very well with using deployment systems like Netlify - which have a far, far more suitable globally available infrastructure than something like DatoCMS or Graphcms. So if im using Netlify as deployment, i would want everything to be served from Netlify domain and let it work its magic.

We understand that this increases build times. This is ok for our usecase where we use a CMS just for the sake of usability, but deployment has to follow guidelines of compliance (geographic restriction of assets, etc) so we would like the entire build to be inside the export folder. This would mean that CMS that have CDN in front of it (e.g. datocms and www.datocms-assets.com which is Imgix) may not be ideal.

There are tons of similar requests.

https://spectrum.chat/next-js/general/how-would-you-handle-importing-remote-images-on-nextjs-static-export~30b2ba84-bc27-4da7-9ec8-21e4d5d287a3

on gatsby side as well - gatsbyjs/gatsby#14076

https://spectrum.chat/gatsby-js/general/adding-remote-images-during-node-creation~e704e6fb-24b2-46c6-b1fc-93189d2e28a4

https://github.com/njosefbeck/gatsby-source-stripe/#downloading-files

@Timer
Copy link
Member

Timer commented Jan 18, 2020

This is covered by #9524

@sandys
Copy link
Author

sandys commented Feb 8, 2020

@Timer sorry for the late response. but this is NOT covered by #9524 . In fact, i was told there to open a new issue since this will not be considered for inclusion under SSG improvements.

Is it possible to do this using any kind of custom code, etc ? this is the only thing blocking us from moving entirely to Nextjs from Gatsby.

@erhankaradeniz
Copy link

@Timer I think @sandys is right here, I'm not seeing anything in that RFC which would solve this issue? Please correct me if I'm wrong, since I'd like to make use of this feature too since I switched to almost 100% SSG pages with the canary builds.

@sandys
Copy link
Author

sandys commented Mar 11, 2020

hi guys,
now that nextjs 9.3 is released with next-gen SSG support ( https://nextjs.org/blog/next-9-3#next-gen-static-site-generation-ssg-support ), im wondering if there is any way to achieve what was mentioned in this bug ?

@sandys
Copy link
Author

sandys commented May 3, 2020

@Timer - any chance you can take a look at this and comment ? if there's a way to do this using the existing Nextjs framework, that would be awesome as well.

@franciscorubin
Copy link

Any news on this? Ideally this should just store images fetched during getStaticProps on .next/static/images like the rest of the images of the website. The fetching will only happen on build time (getStaticProps), so this shouldn't be a problem technically.

@mixtur
Copy link

mixtur commented Jul 30, 2020

I think it should also avoid duplicate downloads and allow post processing of whatever was downloaded afterwards.
So you mark something as an asset in getStaticProps and then in another magic export you do something with it. (Resize, compress etc)

@zommerberg
Copy link

Any news on this?

@Ecksters
Copy link

In my case my headless CMS is internal-only, and only accessible during the build process, currently I'm having to hack together a solution to copy the uploads folder from the headless CMS into my build export's out folder so that the URLs provided by the CMS can be accurate.

It'd be awesome, if NextJS could handle fetching these assets during the build for me, including potentially doing the image optimizations that are already available during the build.

@sandys
Copy link
Author

sandys commented Feb 11, 2021 via email

@vercel vercel locked and limited conversation to collaborators Feb 11, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants