Skip to content

Commit

Permalink
Merge pull request #2 from dmi3y/fix-vercel-no-route-convention
Browse files Browse the repository at this point in the history
[DO NOT MERGE] Fix vercel no route convention
  • Loading branch information
dmi3y authored Mar 8, 2024
2 parents d309cb0 + 4675a36 commit b678c3c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/i18next.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import i18n from '~/i18n'; // your i18n configuration file
import HttpBackend from 'i18next-http-backend';
import {
IS_CF_PAGES,
IS_VERCEL,
safeRequireNodeDependency,
} from '~/utils/platform-adapter';
import { RemixI18NextOption } from 'remix-i18next/build/server';
Expand All @@ -13,6 +14,8 @@ import { findLanguageJSON } from '~/languages.server';
export async function getPlatformBackend() {
if (IS_CF_PAGES) {
return HttpBackend;
} else if (IS_VERCEL) {
return await import('i18next-fs-backend').then((module) => module.default);
} else {
return await safeRequireNodeDependency('i18next-fs-backend').then(
(module) => module.default,
Expand Down
2 changes: 2 additions & 0 deletions app/utils/platform-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export const IS_CF_PAGES = typeof process === 'undefined';

export const IS_VERCEL = 'VERCEL' in process.env;

// This hack is to prevent `node` modules/packages being bundled in the
// Cloudflare Pages context, which causes an error.
export async function safeRequireNodeDependency(module: string) {
Expand Down
4 changes: 2 additions & 2 deletions remix.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const cloudflarePagesConfig = {
*/
const vercelConfig = {
ignoredRouteFiles: ['**/.*'],
...bareConfig,
};
/**
* @type {import('@remix-run/dev').AppConfig}
Expand Down Expand Up @@ -85,5 +86,4 @@ function selectConfig() {
throw new Error(`Cannot select config`);
}

// export default selectConfig();
module.exports = selectConfig();
export default selectConfig();

0 comments on commit b678c3c

Please sign in to comment.