prod build fix

This commit is contained in:
2025-09-16 08:49:25 +02:00
parent 56a88f0a68
commit cbf2e3c738
3 changed files with 37 additions and 9 deletions

View File

@@ -11,7 +11,7 @@ WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f package-lock.json ]; then npm install && npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi

View File

@@ -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,14 +18,34 @@ 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'),
};
webpack: (config, { dev }) => {
// Ensure resolve object exists
config.resolve = config.resolve || {};
config.resolve.alias = config.resolve.alias || {};
// Optional: Add debug logging
// 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);
}

View File

@@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"tsconfig-paths-webpack-plugin": "^4.1.0",
"@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.1.14",
"@radix-ui/react-avatar": "^1.0.4",