|
| 1 | +import { arch, platform } from 'node:os' |
| 2 | +import { readdir } from 'node:fs/promises' |
1 | 3 | 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' |
4 | 6 | import type { NitroEventHandler } from 'nitropack'
|
5 | 7 | import type { HTTPStorageOptions, NodeFSSOptions, IPXOptions } from 'ipx'
|
6 | 8 | import { defu } from 'defu'
|
@@ -73,6 +75,21 @@ export const ipxSetup: IPXSetupT = setupOptions => (providerOptions, moduleOptio
|
73 | 75 | nitro.options._config.runtimeConfig.ipx = defu({ fs: { dir: publicDirs } }, ipxOptions)
|
74 | 76 | nitro.options._config.handlers!.push(ipxHandler)
|
75 | 77 | }
|
| 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 | + } |
76 | 93 | }
|
77 | 94 |
|
78 | 95 | declare module 'nitropack' {
|
|
0 commit comments