diff --git a/.gitignore b/.gitignore index e53e30a..d18260a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules /.cache /build /public/build +/functions/\[\[path\]\].js* diff --git a/functions/[[path]].ts b/functions/[[path]].ts deleted file mode 100644 index ca0a8aa..0000000 --- a/functions/[[path]].ts +++ /dev/null @@ -1,12 +0,0 @@ -import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages'; - -// @ts-ignore -import * as build from '../build'; - -const handleRequest = createPagesFunctionHandler({ - build, -}); - -export function onRequest(context: EventContext) { - return handleRequest(context); -} diff --git a/package.json b/package.json index f1fd90a..1aa7203 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,11 @@ "license": "MIT", "scripts": { "prepare": "husky install", - "build": "cross-env NODE_ENV=production remix build", - "dev": "cross-env NODE_ENV=development run-p dev:*", + "build": "remix build", + "dev": "remix build && run-p dev:*", "dev:remix": "remix watch", - "dev:wrangler": "wrangler pages dev --local ./public", - "start": "yarn run dev:wrangler" + "dev:wrangler": "cross-env NODE_ENV=development wrangler pages dev --local ./public", + "start": "cross-env NODE_ENV=production yarn run dev:wrangler" }, "dependencies": { "@remix-run/cloudflare": "^1.4.3", diff --git a/remix.config.js b/remix.config.js index 9163c6c..33bdbb9 100644 --- a/remix.config.js +++ b/remix.config.js @@ -2,11 +2,8 @@ * @type {import('@remix-run/dev/config').AppConfig} */ module.exports = { - appDirectory: 'app', - assetsBuildDirectory: 'public/build', - publicPath: '/build/', - serverBuildPath: 'build/index.js', serverBuildTarget: 'cloudflare-pages', + server: './server.js', devServerBroadcastDelay: 1000, - ignoredRouteFiles: ['.*'], + ignoredRouteFiles: ['**/.*'], }; diff --git a/server.ts b/server.ts new file mode 100644 index 0000000..a61edb5 --- /dev/null +++ b/server.ts @@ -0,0 +1,11 @@ +import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages'; +import * as build from '@remix-run/dev/server-build'; + +const handleRequest = createPagesFunctionHandler({ + build, + mode: process.env.NODE_ENV, +}); + +export function onRequest(ctx: EventContext) { + return handleRequest(ctx); +}