-
Notifications
You must be signed in to change notification settings - Fork 110
/
remix.config.js
73 lines (68 loc) · 1.82 KB
/
remix.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { createRoutesFromFolders } from '@remix-run/v1-route-convention';
/**
* @type {import('@remix-run/dev').AppConfig}
*/
const commonConfig = {
appDirectory: 'app',
serverModuleFormat: 'esm',
serverDependenciesToBundle: [
'remix-i18next',
'@remix-validated-form/with-zod',
],
tailwind: true,
routes(defineRoutes) {
// uses the v1 convention, works in v1.15+ and v2
return createRoutesFromFolders(defineRoutes);
},
};
/**
* @type {import('@remix-run/dev').AppConfig}
*/
const cloudflarePagesConfig = {
serverBuildPath: 'functions/[[path]].js',
serverPlatform: 'neutral',
server: './server-cloudflare-pages.js',
ignoredRouteFiles: ['**/.*'],
serverMinify: true,
...commonConfig,
};
/**
* @type {import('@remix-run/dev').AppConfig}
*/
const netlifyConfig = {
serverBuildTarget: 'netlify',
server: './server-netlify.js',
ignoredRouteFiles: ['**/.*'],
...commonConfig,
};
/**
* @type {import('@remix-run/dev').AppConfig}
*/
const devConfig = {
appDirectory: 'app',
serverModuleFormat: 'cjs',
devServerPort: 8002,
ignoredRouteFiles: ['.*'],
...commonConfig,
};
/**
* @type {import('@remix-run/dev').AppConfig}
*/
const buildConfig = {
appDirectory: 'app',
assetsBuildDirectory: 'public/build',
publicPath: '/build/',
serverBuildDirectory: 'build',
ignoredRouteFiles: ['.*'],
...commonConfig,
};
function selectConfig() {
if (!['development', 'production'].includes(process.env.NODE_ENV))
throw new Error(`Unknown NODE_ENV: ${process.env.NODE_ENV}`);
if (process.env.CF_PAGES) return cloudflarePagesConfig;
if (process.env.NETLIFY) return netlifyConfig;
if (process.env.NODE_ENV === 'development') return devConfig;
if (!process.env.CF_PAGES && !process.env.NETLIFY) return buildConfig;
throw new Error(`Cannot select config`);
}
export default selectConfig();