|
| 1 | +/* eslint-disable max-lines */ |
1 | 2 | import { promises as fs, existsSync } from 'fs'
|
2 | 3 | import { resolve, join } from 'path'
|
3 | 4 |
|
4 | 5 | import type { NetlifyConfig } from '@netlify/build'
|
5 |
| -import { emptyDir, ensureDir, readJSON, readJson, writeJSON, writeJson } from 'fs-extra' |
| 6 | +import { copyFile, emptyDir, ensureDir, readJSON, readJson, writeJSON, writeJson } from 'fs-extra' |
6 | 7 | import type { MiddlewareManifest } from 'next/dist/build/webpack/plugins/middleware-plugin'
|
7 | 8 |
|
8 | 9 | type EdgeFunctionDefinition = MiddlewareManifest['middleware']['name']
|
@@ -139,7 +140,13 @@ export const writeEdgeFunctions = async (netlifyConfig: NetlifyConfig) => {
|
139 | 140 | 'Using Netlify Edge Functions for image format detection. Set env var "NEXT_DISABLE_EDGE_IMAGES=true" to disable.',
|
140 | 141 | )
|
141 | 142 | }
|
142 |
| - await copyEdgeSourceFile({ edgeFunctionDir: edgeFunctionRoot, file: 'ipx.ts' }) |
| 143 | + const edgeFunctionDir = join(edgeFunctionRoot, 'ipx') |
| 144 | + await ensureDir(edgeFunctionDir) |
| 145 | + await copyEdgeSourceFile({ edgeFunctionDir, file: 'ipx.ts', target: 'index.ts' }) |
| 146 | + await copyFile( |
| 147 | + join('.netlify', 'functions-internal', '_ipx', 'imageconfig.json'), |
| 148 | + join(edgeFunctionDir, 'imageconfig.json'), |
| 149 | + ) |
143 | 150 | manifest.functions.push({
|
144 | 151 | function: 'ipx',
|
145 | 152 | path: '/_next/image*',
|
@@ -183,3 +190,4 @@ export const updateConfig = async (publish: string) => {
|
183 | 190 | config.config.env.NEXT_USE_NETLIFY_EDGE = 'true'
|
184 | 191 | await writeJSON(configFile, config)
|
185 | 192 | }
|
| 193 | +/* eslint-enable max-lines */ |
0 commit comments