mirror of
https://github.com/aljazceru/enclava.git
synced 2025-12-18 07:54:29 +01:00
prod build fix
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
const path = require('path');
|
||||
let TsconfigPathsPlugin;
|
||||
try {
|
||||
// Optional: only used if installed
|
||||
TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
||||
} catch (_) {}
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
@@ -11,17 +18,37 @@ const nextConfig = {
|
||||
},
|
||||
// Enable standalone output for better Docker compatibility
|
||||
output: 'standalone',
|
||||
webpack: (config, { isServer, dev }) => {
|
||||
config.resolve.alias = {
|
||||
...config.resolve.alias,
|
||||
'@': require('path').join(__dirname, 'src'),
|
||||
};
|
||||
|
||||
// Optional: Add debug logging
|
||||
webpack: (config, { dev }) => {
|
||||
// Ensure resolve object exists
|
||||
config.resolve = config.resolve || {};
|
||||
config.resolve.alias = config.resolve.alias || {};
|
||||
|
||||
// Hard-set robust alias for "@" => <repo>/src
|
||||
config.resolve.alias['@'] = path.resolve(__dirname, 'src');
|
||||
|
||||
// Ensure common extensions are resolvable
|
||||
const exts = config.resolve.extensions || [];
|
||||
config.resolve.extensions = Array.from(new Set([...exts, '.ts', '.tsx', '.js', '.jsx']));
|
||||
|
||||
// Add tsconfig-aware resolver plugin if available
|
||||
if (TsconfigPathsPlugin) {
|
||||
const existing = config.resolve.plugins || [];
|
||||
existing.push(
|
||||
new TsconfigPathsPlugin({
|
||||
configFile: path.resolve(__dirname, 'tsconfig.json'),
|
||||
extensions: config.resolve.extensions,
|
||||
mainFields: ['browser', 'module', 'main'],
|
||||
})
|
||||
);
|
||||
config.resolve.plugins = existing;
|
||||
}
|
||||
|
||||
// Optional: Add debug logging in development
|
||||
if (dev) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Webpack alias config:', config.resolve.alias);
|
||||
}
|
||||
|
||||
|
||||
return config;
|
||||
},
|
||||
env: {
|
||||
|
||||
Reference in New Issue
Block a user