-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
87 lines (74 loc) · 2.78 KB
/
next.config.ts
File metadata and controls
87 lines (74 loc) · 2.78 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import type { NextConfig } from 'next'
import path from 'path'
// A helper variable to easily check if we are in static export mode.
const isStaticExport = process.env.NEXT_OUTPUT_MODE === 'export'
console.log(`\n Next.js static export mode: ${isStaticExport}`)
const repoName = 'codebuilder-frontend'
const isGithubPages = !!process.env.GITHUB_PAGES
// Set by the GitHub Pages workflow to support preview deployments in subdirectories.
// e.g. "/codebuilder-frontend" for main, "/codebuilder-frontend/preview/my-branch" for previews.
const ghPagesBasePath = process.env.NEXT_BASE_PATH || ''
const nextConfig = {
/**
* FIX: The 'turbo' settings have been moved to the top-level 'turbopack' property
* as Turbopack is now considered stable in Next.js.
*/
turbopack: {
root: path.resolve(__dirname),
resolveExtensions: ['.mdx', '.tsx', '.ts', '.jsx', '.js', '.mjs', '.json'],
},
// Conditionally set the output mode for the build.
output: isStaticExport ? 'export' : undefined,
basePath: ghPagesBasePath || undefined,
assetPrefix: ghPagesBasePath ? `${ghPagesBasePath}/` : undefined,
allowedDevOrigins: [
'https://api.codebuilder.org',
'https://new.codebuilder.org',
'https://new.codebuilder.org:443',
'https://dev.codebuilder.org',
'https://dev.codebuilder.org:443',
], // resolves the CORS warning
// Note: If you are using next/image, you may need to add an
// unoptimized: true flag here if you are not using a custom loader.
// Conditionally disable image optimization only for the static export.
images: {
unoptimized: isStaticExport,
},
//eslint: {
// ignoreDuringBuilds: true,
//},
// Enable logging configuration
logging: {
fetches: {
fullUrl: true,
},
},
// Ensure proper console output in Docker containers
experimental: {
// This helps with console output in Docker
// forceSwcTransforms: true,
},
/**
* Note: The 'webpack' configuration below is applied when you run 'next build'
* or the standard 'next dev'. It is ignored when you run 'next dev --turbopack',
* as Turbopack uses its own Rust-based compiler.
*/
webpack: (config, { isServer }) => {
// Modify Webpack's watchOptions
config.watchOptions = {
poll: 1000, // Enable polling
aggregateTimeout: 300, // Delay before rebuilding
ignored: /node_modules/, // Example: Exclude node_modules
}
return config
},
} as unknown as NextConfig
// // Only include page.* files for static export, include route.* for all other builds
// if (isStaticExport) {
// (nextConfig as any).pageExtensions = ['page.tsx', 'page.ts', 'page.jsx', 'page.js']
// } else {
// (nextConfig as any).pageExtensions = [
// 'route.ts', 'route.js', 'page.tsx', 'page.ts', 'page.jsx', 'page.js'
// ]
// }
export default nextConfig