fix(nitro): generate correct netlify entrypoint (#372)

This commit is contained in:
Matt Kane 2021-07-26 11:37:39 +01:00 committed by GitHub
parent a57b9e1887
commit e43e9cf71a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

1
.gitignore vendored
View File

@ -62,3 +62,4 @@ Temporary Items
.vercel_build_output .vercel_build_output
.build-* .build-*
.env .env
.netlify

View File

@ -9,6 +9,7 @@ import type { NodeExternalsOptions } from './rollup/plugins/externals'
import type { StorageOptions } from './rollup/plugins/storage' import type { StorageOptions } from './rollup/plugins/storage'
import type { AssetOptions } from './rollup/plugins/assets' import type { AssetOptions } from './rollup/plugins/assets'
import type { ServerMiddleware } from './server/middleware' import type { ServerMiddleware } from './server/middleware'
import type { RollupConfig } from './rollup/config'
export interface NitroContext { export interface NitroContext {
timing: boolean timing: boolean
@ -20,7 +21,7 @@ export interface NitroContext {
entry: string entry: string
node: boolean node: boolean
preset: string preset: string
rollupConfig?: any rollupConfig?: RollupConfig
renderer: string renderer: string
serveStatic: boolean serveStatic: boolean
middleware: ServerMiddleware[] middleware: ServerMiddleware[]

View File

@ -7,7 +7,7 @@ import { lambda } from './lambda'
export const netlify: NitroPreset = extendPreset(lambda, { export const netlify: NitroPreset = extendPreset(lambda, {
output: { output: {
dir: '{{ _nuxt.rootDir }}/netlify/functions', dir: '{{ _nuxt.rootDir }}/.netlify/functions-internal',
publicDir: '{{ _nuxt.rootDir }}/dist' publicDir: '{{ _nuxt.rootDir }}/dist'
}, },
hooks: { hooks: {
@ -24,6 +24,9 @@ export const netlify: NitroPreset = extendPreset(lambda, {
contents = currentRedirects + '\n' + contents contents = currentRedirects + '\n' + contents
} }
await writeFile(redirectsPath, contents) await writeFile(redirectsPath, contents)
},
'nitro:rollup:before' (ctx: NitroContext) {
ctx.rollupConfig.output.entryFileNames = 'server.ts'
} }
}, },
ignore: [ ignore: [

View File

@ -1,6 +1,5 @@
// @ts-ignore import { builder } from '@netlify/functions'
import { builderFunction } from '@netlify/functions'
// @ts-ignore // @ts-ignore
import { handler as _handler } from '#nitro/entries/lambda' import { handler as _handler } from '#nitro/entries/lambda'
export const handler = builderFunction(_handler) export const handler = builder(_handler)