Skip to content

Commit b78c0ea

Browse files
authored
feat(ipx): log the architecture of the build (#1808)
1 parent af94f2d commit b78c0ea

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/ipx.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { arch, platform } from 'node:os'
2+
import { readdir } from 'node:fs/promises'
13
import { existsSync } from 'node:fs'
2-
import { relative, resolve } from 'pathe'
3-
import { useNuxt, createResolver, useNitro } from '@nuxt/kit'
4+
import { join, relative, resolve } from 'pathe'
5+
import { useNuxt, createResolver, useNitro, useLogger } from '@nuxt/kit'
46
import type { NitroEventHandler } from 'nitropack'
57
import type { HTTPStorageOptions, NodeFSSOptions, IPXOptions } from 'ipx'
68
import { defu } from 'defu'
@@ -73,6 +75,21 @@ export const ipxSetup: IPXSetupT = setupOptions => (providerOptions, moduleOptio
7375
nitro.options._config.runtimeConfig.ipx = defu({ fs: { dir: publicDirs } }, ipxOptions)
7476
nitro.options._config.handlers!.push(ipxHandler)
7577
}
78+
79+
if (!nuxt.options.dev && !setupOptions?.isStatic) {
80+
nitro.hooks.hook('compiled', async () => {
81+
const logger = useLogger('@nuxt/image')
82+
const target = `${platform}-${arch}`
83+
const tracedFiles = await readdir(join(nitro.options.output.serverDir, 'node_modules/@img')).catch(() => [])
84+
if (!tracedFiles.length) {
85+
logger.warn(`\`sharp\` binaries for \`${target}\` cannot be found. Please report this as a bug with a reproduction at \`https://github.com/nuxt/image\`.`)
86+
}
87+
else {
88+
logger.info(`\`sharp\` binaries have been included in your build for \`${target}\`. Make sure you deploy to the same architecture.`)
89+
logger.debug(` - dependencies traced: ${tracedFiles.map(f => `@img/${f}`).join(', ')}`)
90+
}
91+
})
92+
}
7693
}
7794

7895
declare module 'nitropack' {

0 commit comments

Comments
 (0)