-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
67 lines (57 loc) · 1.7 KB
/
next.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
/** @type {import('next').NextConfig} */
const path = require('path');
const fs = require('fs');
const nextConfig = {
async rewrites() {
return [
{
source: '/:any*',
destination: '/',
},
]
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**',
},
],
},
webpack: (config, { isServer }) => {
if (isServer) {
const protoDir = path.join(process.cwd(), 'public', 'protos')
const targetDirs = [
path.join(process.cwd(), '.next', 'server', 'protos'),
path.join(process.cwd(), '.next', 'server', 'app', 'protos'),
]
const expectedFiles = [
path.join(protoDir, 'core', 'v0', 'core.proto'),
path.join(protoDir, 'platform', 'v0', 'platform.proto')
];
const missingFiles = expectedFiles.filter(file => !fs.existsSync(file));
if (!fs.existsSync(protoDir)) {
console.error('Error: Directory with proto files not found:', protoDir);
return config;
}
if (missingFiles.length > 0) {
console.error('Error: The following proto files are missing:');
missingFiles.forEach(file => console.error(`- ${file}`));
return config;
}
try {
for (const targetDir of targetDirs) {
fs.mkdirSync(targetDir, { recursive: true });
fs.cpSync(protoDir, targetDir, { recursive: true });
console.log('Proto files successfully copied from:', protoDir);
console.log('To:', targetDir);
}
} catch (error) {
console.error('Error copying proto files:', error);
}
}
config.optimization = {minimize: false};
return config;
}
}
module.exports = nextConfig