chore(frontend+infra): optimize build process and exclude SQLite workers from minification
- Updated Webpack config to exclude SQLite workers from parsing and Terser minification, fixing related errors and improving build speed. - Adjusted Dockerfile to disable source maps for production builds, reducing build time and memory usage. - Modified Gradle build configuration to respect the `noSourceMaps` flag during Docker builds.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user