image
image copied to clipboard
Provider for dev/build only
Is it possible to save images from a provider like sanity to the dist folder on build? Or would that result in more bandwidth longterm?
I would advise against it, personally, for exactly that reason. But it would be possible to do that using a custom static provider, for example:
export default {
target: 'static',
buildModules: ['@nuxt/image'],
image: {
providers: {
custom: {
provider: '~/providers/sanity-static',
options: {
projectId: 'YOUR_PROJECT_ID'
}
},
},
provider: 'custom',
}
};
Then with a providers/sanity-static.js
file:
import { getImage as _getImage } from '@nuxt/image/dist/runtime/providers/sanity'
export const getImage = (src, options, ctx) => ({
..._getImage(src, options, ctx),
isStatic: true
})