-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.mjs
More file actions
50 lines (41 loc) · 1.39 KB
/
next.config.mjs
File metadata and controls
50 lines (41 loc) · 1.39 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
/** @type {import('next').NextConfig} */
const nextConfig = {
// Enable experimental features for better serverless compatibility
experimental: {
serverComponentsExternalPackages: ['puppeteer-core', '@sparticuz/chromium']
},
// Webpack configuration to handle Puppeteer dependencies
webpack: (config, { isServer }) => {
if (isServer) {
// Exclude puppeteer from client bundle
config.externals = config.externals || [];
config.externals.push({
'puppeteer': 'commonjs puppeteer',
'puppeteer-core': 'commonjs puppeteer-core',
'@sparticuz/chromium': 'commonjs @sparticuz/chromium'
});
}
// Handle binary files and native modules
config.resolve.alias = {
...config.resolve.alias,
};
// Ignore specific warnings related to Puppeteer
config.ignoreWarnings = [
{ module: /puppeteer/ },
{ module: /@sparticuz\/chromium/ },
];
return config;
},
// Output configuration for better serverless deployment
output: 'standalone',
// Enable minification for better performance
swcMinify: true,
// Disable static optimization for API routes that use Puppeteer
generateStaticParams: false,
// Environment variables configuration (optional)
env: {
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true',
PUPPETEER_EXECUTABLE_PATH: '', // Will be set by @sparticuz/chromium
},
}
export default nextConfig;