2024-04-07 10:04:56 +00:00
|
|
|
import fs from 'fs';
|
|
|
|
|
2024-03-12 10:40:53 +00:00
|
|
|
let baseAssetUrl = process.env.ASSET_URL ?? '/';
|
|
|
|
if (!baseAssetUrl.endsWith('/')) baseAssetUrl += '/';
|
|
|
|
|
|
|
|
let basePath = process.env.BASE_PATH ?? '';
|
|
|
|
if (basePath.endsWith('/')) basePath = basePath.slice(0, -1);
|
|
|
|
|
2024-04-07 10:04:56 +00:00
|
|
|
const packageInfo = JSON.parse(fs.readFileSync('package.json').toString());
|
|
|
|
|
|
|
|
let versionString = `Actaeon v${packageInfo.version}`;
|
|
|
|
|
|
|
|
try {
|
|
|
|
const rev = fs.readFileSync('.git/HEAD').toString().trim();
|
|
|
|
if (!rev.includes(':'))
|
|
|
|
versionString += ` (${rev})`;
|
|
|
|
const branch = rev.replace(/^ref:\s+refs\/heads\//, '');
|
|
|
|
const hash = fs.readFileSync(`.git/${rev.slice(5)}`).toString().trim();
|
|
|
|
if (branch !== 'main')
|
|
|
|
versionString += ` on ${branch}`;
|
|
|
|
versionString += ` (${hash.slice(0, 8)})`;
|
|
|
|
} catch { }
|
|
|
|
|
2024-03-12 10:40:53 +00:00
|
|
|
/** @type {import('next').NextConfig} */
|
|
|
|
const nextConfig = {
|
|
|
|
images: {
|
|
|
|
unoptimized: true
|
|
|
|
},
|
|
|
|
basePath,
|
|
|
|
async redirects() {
|
|
|
|
return [...(basePath ? [{
|
|
|
|
source: '/',
|
|
|
|
destination: basePath,
|
|
|
|
permanent: false,
|
|
|
|
basePath: false
|
|
|
|
}] : []), {
|
|
|
|
source: '/chuni',
|
|
|
|
destination: '/chuni/dashboard',
|
|
|
|
permanent: false
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
env: {
|
|
|
|
NEXT_PUBLIC_BASE_PATH: basePath,
|
2024-04-07 10:04:56 +00:00
|
|
|
NEXT_PUBLIC_ASSET_URL: baseAssetUrl,
|
|
|
|
NEXT_PUBLIC_VERSION_STRING: versionString
|
2024-03-12 10:40:53 +00:00
|
|
|
},
|
|
|
|
sassOptions: {
|
|
|
|
additionalData: `$asset-url: "${baseAssetUrl}";`
|
2024-03-24 10:04:59 +00:00
|
|
|
},
|
|
|
|
experimental: {
|
|
|
|
instrumentationHook: true
|
|
|
|
},
|
2024-03-28 00:34:41 +00:00
|
|
|
productionBrowserSourceMaps: true,
|
|
|
|
webpack: config => {
|
2024-03-30 10:29:55 +00:00
|
|
|
config.externals = [...config.externals, 'bcrypt', 'mysql2'];
|
2024-03-28 00:34:41 +00:00
|
|
|
return config;
|
|
|
|
}
|
2024-03-12 10:40:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default nextConfig;
|