-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnext.config.ts
More file actions
50 lines (44 loc) · 1.57 KB
/
next.config.ts
File metadata and controls
50 lines (44 loc) · 1.57 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
import type { Configuration } from 'webpack';
import path from 'path';
const isProd = process.env.NODE_ENV === 'production';
const basePath = isProd ? (process.env.BASE_PATH || '') : '';
// const targetFolder = process.env.TARGET_FOLDER || '';
const assetPrefix = isProd ? (basePath ? `${basePath.replace(/\/$/, '')}/` : '') : '';
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export' as const,
basePath: basePath,
trailingSlash: true,
assetPrefix: assetPrefix,
images: {
unoptimized: true,
},
// Turbopack config for dev mode
turbopack: {
rules: {
'*.{glsl,vs,fs,vert,frag}': {
loaders: ['raw-loader'],
as: '*.js',
},
},
},
// Webpack config for build mode
webpack: (config: Configuration) => {
if (!config.module) config.module = { rules: [] };
if (!config.module.rules) config.module.rules = [];
config.module.rules.push({
test: /\.(glsl|vs|fs|vert|frag)$/,
type: 'asset/source',
});
// Add path alias resolution
if (!config.resolve) config.resolve = { alias: {} };
if (!config.resolve.alias) config.resolve.alias = {};
// Explicitly set path aliases to match tsconfig.json
(config.resolve.alias as { [key: string]: string })['@'] = path.resolve(__dirname, 'src');
(config.resolve.alias as { [key: string]: string })['@/components'] = path.resolve(__dirname, 'src/components');
return config;
},
};
console.log('Current NODE_ENV:', process.env.NODE_ENV);
// console.log('Current basePath:', nextConfig.basePath);
export default nextConfig;