Skip to content

Commit b7d7e71

Browse files
committed
hotfix: attempt to fix breaking Next version update
1 parent 499a840 commit b7d7e71

3 files changed

Lines changed: 101 additions & 7 deletions

File tree

Website/next.config.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
import type { NextConfig } from "next";
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
output: 'standalone',
4+
// Ensure static files are properly handled in standalone mode
5+
experimental: {
6+
outputFileTracingIncludes: {
7+
'/': ['./public/**/*'],
8+
},
9+
},
10+
// Configure the standalone build to include static assets
11+
generateBuildId: async () => {
12+
return 'build-' + Date.now()
13+
},
14+
// Add this to ensure proper static file handling
15+
trailingSlash: false,
16+
// Configure asset optimization
17+
assetPrefix: process.env.NODE_ENV === 'production' ? '' : '',
18+
}
219

3-
const nextConfig: NextConfig = {
4-
/* config options here */
5-
output: 'standalone'
6-
};
7-
8-
export default nextConfig;
20+
module.exports = nextConfig

Website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
8+
"postbuild": "node scripts/postBuild.js",
89
"start": "next start",
910
"lint": "next lint",
1011
"prepipeline": "node scripts/copyStub.js"

Website/scripts/postBuild.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
function copyDirectorySync(src, dest) {
5+
try {
6+
// Check if source exists
7+
if (!fs.existsSync(src)) {
8+
console.log(`Source directory ${src} does not exist, skipping...`);
9+
return;
10+
}
11+
12+
// Create destination directory if it doesn't exist
13+
if (!fs.existsSync(dest)) {
14+
fs.mkdirSync(dest, { recursive: true });
15+
}
16+
17+
// Read directory contents
18+
const entries = fs.readdirSync(src, { withFileTypes: true });
19+
20+
for (const entry of entries) {
21+
const srcPath = path.join(src, entry.name);
22+
const destPath = path.join(dest, entry.name);
23+
24+
if (entry.isDirectory()) {
25+
copyDirectorySync(srcPath, destPath);
26+
} else {
27+
fs.copyFileSync(srcPath, destPath);
28+
}
29+
}
30+
31+
console.log(`Successfully copied ${src} to ${dest}`);
32+
} catch (error) {
33+
console.error(`Error copying ${src} to ${dest}:`, error.message);
34+
}
35+
}
36+
37+
function moveDirectorySync(src, dest) {
38+
try {
39+
// Check if source exists
40+
if (!fs.existsSync(src)) {
41+
console.log(`Source directory ${src} does not exist, skipping...`);
42+
return;
43+
}
44+
45+
// Create destination directory if it doesn't exist
46+
const destDir = path.dirname(dest);
47+
if (!fs.existsSync(destDir)) {
48+
fs.mkdirSync(destDir, { recursive: true });
49+
}
50+
51+
// Move the directory
52+
fs.renameSync(src, dest);
53+
console.log(`Successfully moved ${src} to ${dest}`);
54+
} catch (error) {
55+
console.error(`Error moving ${src} to ${dest}:`, error.message);
56+
}
57+
}
58+
59+
// Check if we're in a CI environment (Azure DevOps sets BUILD_SOURCESDIRECTORY)
60+
const isCI = process.env.BUILD_SOURCESDIRECTORY || process.env.CI;
61+
62+
// Move static files (this is generated, so we can always move it)
63+
const staticSrc = '.next/static';
64+
const staticDest = '.next/standalone/.next/static';
65+
moveDirectorySync(staticSrc, staticDest);
66+
67+
// Handle public folder differently for CI vs local
68+
const publicSrc = 'public';
69+
const publicDest = '.next/standalone/public';
70+
71+
if (isCI) {
72+
// In CI, we can move since it's a clean environment
73+
moveDirectorySync(publicSrc, publicDest);
74+
console.log('CI environment detected - moved public folder');
75+
} else {
76+
// Locally, copy to avoid git changes
77+
copyDirectorySync(publicSrc, publicDest);
78+
console.log('Local environment detected - copied public folder');
79+
}
80+
81+
console.log('Post-build file organization complete');

0 commit comments

Comments
 (0)