Skip to content

Commit 4d8aab0

Browse files
committed
feat(vercel): set image config using v3 output api
(requires nitro 0.5.2+)
1 parent 4c23770 commit 4d8aab0

3 files changed

Lines changed: 226 additions & 204 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ dist/
77
coverage
88
sw.*
99
.vscode
10-
.vercel_build_output
10+
.vercel
1111
.output

src/provider.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { promises as fsp } from 'fs'
2-
import { normalize, resolve, dirname } from 'pathe'
1+
import { normalize } from 'pathe'
2+
import { defu } from 'defu'
3+
import type { Nuxt } from '@nuxt/schema'
34
import { createResolver, resolvePath } from '@nuxt/kit'
45
import { hash } from 'ohash'
56
import type { InputProvider, ImageModuleProvider, ProviderSetup } from './types'
@@ -35,13 +36,17 @@ export const providerSetup: Record<string, ProviderSetup> = {
3536
static: ipxSetup,
3637

3738
// https://vercel.com/docs/more/adding-your-framework#images
38-
async vercel (_providerOptions, moduleOptions, nuxt) {
39-
const imagesConfig = resolve(nuxt.options.rootDir, '.vercel_build_output/config/images.json')
40-
await fsp.mkdir(dirname(imagesConfig), { recursive: true })
41-
await fsp.writeFile(imagesConfig, JSON.stringify({
42-
domains: moduleOptions.domains,
43-
sizes: Array.from(new Set(Object.values(moduleOptions.screens || {})))
44-
}, null, 2))
39+
vercel (_providerOptions, moduleOptions, nuxt: Nuxt) {
40+
nuxt.options.nitro = defu(nuxt.options.nitro, {
41+
vercel: {
42+
config: {
43+
image: {
44+
domains: moduleOptions.domains,
45+
sizes: Array.from(new Set(Object.values(moduleOptions.screens || {})))
46+
}
47+
}
48+
}
49+
})
4550
}
4651
}
4752

0 commit comments

Comments
 (0)