-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.mjs
More file actions
34 lines (30 loc) · 827 Bytes
/
next.config.mjs
File metadata and controls
34 lines (30 loc) · 827 Bytes
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
import fs from 'fs';
const pckg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
/** @type {import('next').NextConfig} */
const nextConfig = {
typescript: {
tsconfigPath: './tsconfig.next.json',
},
distDir: pckg.serverPath,
basePath: '',
webpack: (config) => {
config.resolve.extensionAlias = {
'.js': ['.ts', '.tsx', '.js', '.jsx'],
};
return config;
},
};
const CLIENT = +process.env.CLIENT;
if (CLIENT) {
console.log('deep:', 'client building to ./client');
nextConfig.distDir = pckg.clientPath;
nextConfig.output = 'export';
} else {
console.log('deep:', 'server building to ./server');
}
const BASE_PATH = process.env.BASE_PATH;
if (BASE_PATH) {
console.log('deep:', 'BASE_PATH detected:', BASE_PATH);
nextConfig.basePath = BASE_PATH;
}
export default nextConfig;