forked from masonfox/tome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
61 lines (54 loc) · 1.83 KB
/
next.config.ts
File metadata and controls
61 lines (54 loc) · 1.83 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
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
output: 'standalone',
experimental: {
// Skip pre-rendering for pages that fail
workerThreads: false,
cpus: 1,
// Enable optimized package imports for better tree-shaking
optimizePackageImports: ['lucide-react', 'date-fns'],
},
images: {
unoptimized: true, // Required for local file system images
},
compiler: {
removeConsole: process.env.NODE_ENV === 'production' ? {
exclude: ['error', 'warn'],
} : false,
},
// Turbopack configuration (empty for now, may need future migration)
turbopack: {},
// Externalize native modules for server-side rendering
// Note: pino and pino-pretty are already in Next.js default external packages list
serverExternalPackages: ['better-sqlite3'],
webpack: (config, { isServer, dev }) => {
if (isServer) {
// Additional webpack externals configuration for Next.js 16
// This ensures native modules are not bundled
if (!config.externals) {
config.externals = [];
}
// Handle externals as a function or array
const externals = Array.isArray(config.externals) ? config.externals : [config.externals];
// Add our native modules to externals
// Note: pino and pino-pretty are already in Next.js default external packages list
externals.push(({ request }: any, callback: any) => {
if (request === 'better-sqlite3') {
return callback(null, `commonjs ${request}`);
}
callback();
});
config.externals = externals;
}
// Enable better tree-shaking in production
if (!dev) {
config.optimization = {
...config.optimization,
usedExports: true,
sideEffects: false,
};
}
return config;
},
};
export default nextConfig;