Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE fix: deploy with vercel #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions remix.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createRoutesFromFolders } = require('@remix-run/v1-route-convention');
// const { createRoutesFromFolders } = require('@remix-run/v1-route-convention');

/**
* @type {import('@remix-run/dev').AppConfig}
Expand All @@ -8,6 +8,14 @@ const cloudflarePagesConfig = {
server: './server-cloudflare-pages.js',
ignoredRouteFiles: ['**/.*'],
};
/**
* @type {import('@remix-run/dev').AppConfig}
*/
const vercelConfig = {
// serverBuildTarget: 'netlify',
// server: './server-netlify.js',
ignoredRouteFiles: ['**/.*'],
};
/**
* @type {import('@remix-run/dev').AppConfig}
*/
Expand All @@ -27,10 +35,10 @@ const devConfig = {
future: {
v2_dev: true,
},
routes(defineRoutes) {
// uses the v1 convention, works in v1.15+ and v2
return createRoutesFromFolders(defineRoutes);
},
// routes(defineRoutes) {
// // uses the v1 convention, works in v1.15+ and v2
// return createRoutesFromFolders(defineRoutes);
// },
};

/**
Expand All @@ -44,14 +52,26 @@ const buildConfig = {
ignoredRouteFiles: ['.*'],
};

// function selectConfig() {
// if (!['development', 'production'].includes(process.env.NODE_ENV))
// throw `Unknown NODE_ENV: ${process.env.NODE_ENV}`;
// if (process.env.NODE_ENV === 'development') return devConfig;
// if (!process.env.CF_PAGES && !process.env.NETLIFY) return buildConfig;
// if (process.env.CF_PAGES) return cloudflarePagesConfig;
// if (process.env.NETLIFY) return netlifyConfig;
// throw `Cannot select config`;
// }

function selectConfig() {
if (!['development', 'production'].includes(process.env.NODE_ENV))
throw `Unknown NODE_ENV: ${process.env.NODE_ENV}`;
if (process.env.NODE_ENV === 'development') return devConfig;
if (!process.env.CF_PAGES && !process.env.NETLIFY) return buildConfig;
const ENV = process.env?.NODE_ENV || process.env?.VERCEL_ENV;
if (!['preview', 'development', 'production'].includes(ENV))
throw new Error(`Unknown ENV: ${ENV}`);
if (process.env.CF_PAGES) return cloudflarePagesConfig;
if (process.env.NETLIFY) return netlifyConfig;
throw `Cannot select config`;
if (process.env.VERCEL) return vercelConfig;
if (ENV === 'development') return devConfig;
if (!process.env.CF_PAGES && !process.env.NETLIFY) return buildConfig;
throw new Error(`Cannot select config`);
}

module.exports = selectConfig();