Skip to content

Commit

Permalink
chore: fix build command
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Oct 17, 2023
1 parent 310d766 commit 5a9314e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/demo-site/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build]
# command = "npm run build && echo '{\"config\":{\"nodeModuleFormat\":\"esm\"},\"version\":1}' > .netlify/functions-internal/server.json"
command = "npm run build"
publish = "public"
command = "npm run build -w=packages/demo-site"
# command = "npm run build"
publish = "/packages/demo-site/public"

[dev]
command = "npm run dev -w packages/demo-site"
Expand Down
7 changes: 4 additions & 3 deletions packages/demo-site/server.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import * as build from '@remix-run/dev/server-build'
import { createRequestHandler } from '@netlify/remix-adapter'
import type { Config } from '@netlify/functions'
import type { Context, Config } from '@netlify/functions'

const handle = createRequestHandler({
build,
mode: process.env.NODE_ENV,
})

export default function handler(event, context) {
return handle(event, context)
export default function handler(request: Request, context: Context) {
console.log('handler')
return handle(request, context)
}

export const config: Config = {
Expand Down
5 changes: 4 additions & 1 deletion packages/remix-adapter/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ export function createRequestHandler({
mode?: string
getLoadContext?: GetLoadContextFunction
}): RequestHandler {
console.log('createRequestHandler')
const remixHandler = createRemixRequestHandler(build, mode)

return async (request: Request, context: LoadContext): Promise<Response | void> => {
const start = Date.now()
console.log(`[${request.method}] ${request.url}`)
try {
const loadContext = (await getLoadContext?.(request, context)) || context

const response = await remixHandler(request, loadContext)

// A useful header for debugging
response.headers.set('x-nf-runtime', 'Node')

console.log(`[${response.status}] ${request.url} (${Date.now() - start}ms)`)
return response
} catch (error: unknown) {
console.error(error)
Expand Down

0 comments on commit 5a9314e

Please sign in to comment.