diff --git a/config/docker/nginx/web-app/Dockerfile b/config/docker/nginx/web-app/Dockerfile index 2be90362..e13a9c61 100644 --- a/config/docker/nginx/web-app/Dockerfile +++ b/config/docker/nginx/web-app/Dockerfile @@ -1,13 +1,13 @@ # syntax=docker/dockerfile:1.8 # =================================================================== # Multi-Stage Dockerfile for Meldestelle Web-App (Kotlin/JS) -# Version: 2.3.0 - Optimized for Production Build +# Version: 2.3.1 - Optimized for Production Build (No Source Maps) # =================================================================== # === GLOBAL ARGS === -ARG GRADLE_VERSION=8.5 -ARG JAVA_VERSION=21 -ARG NGINX_IMAGE_TAG=1.25-alpine +ARG GRADLE_VERSION=9.2.1 +ARG JAVA_VERSION=25 +ARG NGINX_IMAGE_TAG=1.28-alpine ARG VERSION=1.0.0-SNAPSHOT ARG BUILD_DATE @@ -49,10 +49,12 @@ RUN mkdir -p docs # 4. Build Web App (Production Only) # We explicitly build the production distribution for optimized artifacts. +# Added -PnoSourceMaps=true to disable source maps and speed up build/reduce memory usage. RUN --mount=type=cache,target=/home/gradle/.gradle/caches \ --mount=type=cache,target=/home/gradle/.gradle/wrapper \ ./gradlew :frontend:shells:meldestelle-portal:jsBrowserDistribution \ -Pproduction=true \ + -PnoSourceMaps=true \ --no-daemon \ --stacktrace diff --git a/frontend/shells/meldestelle-portal/build.gradle.kts b/frontend/shells/meldestelle-portal/build.gradle.kts index 5e624a9b..2225ca74 100644 --- a/frontend/shells/meldestelle-portal/build.gradle.kts +++ b/frontend/shells/meldestelle-portal/build.gradle.kts @@ -39,6 +39,11 @@ kotlin { KotlinWebpackConfig.Mode.PRODUCTION else KotlinWebpackConfig.Mode.DEVELOPMENT + + // Source Maps Optimierung für Docker Builds + if (project.hasProperty("noSourceMaps")) { + sourceMaps = false + } } webpackTask { diff --git a/frontend/shells/meldestelle-portal/webpack.config.d/sqlite-config.js b/frontend/shells/meldestelle-portal/webpack.config.d/sqlite-config.js index e9477fdf..08945f79 100644 --- a/frontend/shells/meldestelle-portal/webpack.config.d/sqlite-config.js +++ b/frontend/shells/meldestelle-portal/webpack.config.d/sqlite-config.js @@ -136,3 +136,28 @@ config.devServer.devMiddleware.mimeTypes = { 'application/wasm': ['wasm'], 'application/javascript': ['js'] }; + +// 10. OPTIMIZATION: Exclude SQLite workers from parsing and minification +// This fixes the "return outside of function" error in Terser and speeds up build +config.module.noParse = config.module.noParse || []; +if (Array.isArray(config.module.noParse)) { + config.module.noParse.push(/sqlite3-worker1\.mjs/); + config.module.noParse.push(/sqlite3\.mjs/); +} else { + // If it's a function or RegExp, we wrap it (simplified for now, assuming array or undefined) + config.module.noParse = [config.module.noParse, /sqlite3-worker1\.mjs/, /sqlite3\.mjs/]; +} + +if (config.optimization && config.optimization.minimizer) { + config.optimization.minimizer.forEach(minimizer => { + if (minimizer.constructor.name === 'TerserPlugin') { + minimizer.options.exclude = minimizer.options.exclude || []; + const excludePattern = /sqlite3-worker1\.mjs/; + if (Array.isArray(minimizer.options.exclude)) { + minimizer.options.exclude.push(excludePattern); + } else { + minimizer.options.exclude = [minimizer.options.exclude, excludePattern]; + } + } + }); +}