|
1 | 1 | import fs from 'fs' |
2 | 2 | import path from 'path' |
| 3 | +import type { NextConfig } from 'next' |
3 | 4 |
|
4 | 5 | import frontmatter from '@gr2m/gray-matter' |
5 | | -// Hardcoded log level function since next.config.js cannot import from TypeScript files |
6 | | -// Matches ./src/observability/logger/lib/log-levels |
7 | | -function getLogLevelNumber() { |
8 | | - const LOG_LEVELS = { |
9 | | - error: 0, |
10 | | - warn: 1, |
11 | | - info: 2, |
12 | | - debug: 3, |
13 | | - } |
| 6 | +import { getLogLevelNumber } from '@/observability/logger/lib/log-levels' |
14 | 7 |
|
15 | | - let defaultLogLevel = 'info' |
16 | | - if ( |
17 | | - !process.env.LOG_LEVEL && |
18 | | - (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test') |
19 | | - ) { |
20 | | - defaultLogLevel = 'debug' |
21 | | - } |
22 | | - |
23 | | - const envLogLevel = process.env.LOG_LEVEL?.toLowerCase() || defaultLogLevel |
24 | | - const logLevel = LOG_LEVELS[envLogLevel] !== undefined ? envLogLevel : defaultLogLevel |
25 | | - |
26 | | - return LOG_LEVELS[logLevel] |
27 | | -} |
28 | | - |
29 | | -// Replace imports with hardcoded values |
30 | 8 | const ROOT = process.env.ROOT || '.' |
31 | 9 |
|
32 | | -// Hard-coded language keys to avoid TypeScript import in config file |
| 10 | +// Language keys are defined here because Next.js config compilation doesn't resolve the @/ path alias |
| 11 | +// Importing from src/languages/lib/languages.ts would fail when it tries to import @/frame/lib/constants |
| 12 | +// This must match the languages defined in src/languages/lib/languages.ts |
33 | 13 | const languageKeys = ['en', 'es', 'ja', 'pt', 'zh', 'ru', 'fr', 'ko', 'de'] |
34 | 14 |
|
35 | 15 | const homepage = path.posix.join(ROOT, 'content/index.md') |
36 | 16 | const { data } = frontmatter(fs.readFileSync(homepage, 'utf8')) |
37 | | -const productIds = data.children |
| 17 | +const productIds = data.children as string[] |
38 | 18 |
|
39 | | -export default { |
| 19 | +const config: NextConfig = { |
40 | 20 | // Transpile @primer/react so Next's webpack can process its CSS and other assets |
41 | 21 | // This ensures CSS in node_modules/@primer/react is handled by the app's loaders. |
42 | 22 | transpilePackages: ['@primer/react'], |
@@ -106,3 +86,5 @@ export default { |
106 | 86 | styledComponents: true, |
107 | 87 | }, |
108 | 88 | } |
| 89 | + |
| 90 | +export default config |
0 commit comments