fixing Web-App

This commit is contained in:
2025-09-27 00:21:56 +02:00
parent 85249be62c
commit 6a40375e3f
4 changed files with 115 additions and 17 deletions
+33 -2
View File
@@ -1,6 +1,8 @@
@file:OptIn(ExperimentalKotlinGradlePluginApi::class) @file:OptIn(ExperimentalKotlinGradlePluginApi::class)
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
/** /**
* Dieses Modul ist der "Host". Es kennt alle Features und die Shared-Module und * Dieses Modul ist der "Host". Es kennt alle Features und die Shared-Module und
@@ -31,12 +33,30 @@ kotlin {
js(IR) { js(IR) {
outputModuleName = "web-app" outputModuleName = "web-app"
browser { browser {
commonWebpackConfig { webpackTask {
cssSupport { enabled = true } mainOutputFileName = "web-app.js"
output.libraryTarget = "commonjs2"
} }
// Development Server konfigurieren
runTask {
mainOutputFileName.set("web-app.js")
}
// Browser-Tests komplett deaktivieren (Configuration Cache kompatibel)
testTask { testTask {
enabled = false enabled = false
} }
commonWebpackConfig {
cssSupport { enabled = true }
// Webpack-Mode abhängig von Build-Typ
mode = if (project.hasProperty("production"))
KotlinWebpackConfig.Mode.PRODUCTION
else
KotlinWebpackConfig.Mode.DEVELOPMENT
}
} }
binaries.executable() binaries.executable()
} }
@@ -94,6 +114,17 @@ kotlin {
} }
} }
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.addAll(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xskip-metadata-version-check" // Für bleeding-edge Versionen
)
}
}
// Configure duplicate handling strategy for distribution tasks // Configure duplicate handling strategy for distribution tasks
tasks.withType<Tar> { tasks.withType<Tar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+62 -3
View File
@@ -1,10 +1,69 @@
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path'); const path = require('path');
// Template-Pfad für deine index.html
const templatePath = path.resolve(__dirname, '../../../../clients/app/src/jsMain/resources/index.html'); const templatePath = path.resolve(__dirname, '../../../../clients/app/src/jsMain/resources/index.html');
// Erweitere die bestehende Kotlin/JS Webpack-Konfiguration
config.plugins.push(new HtmlWebpackPlugin({ config.plugins.push(new HtmlWebpackPlugin({
template: templatePath, template: templatePath,
filename: 'index.html', filename: 'index.html',
inject: 'body', inject: 'body',
// Optimierung hinzufügen
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
removeEmptyAttributes: true,
useShortDoctype: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
}
})); }));
// Bundle-Analyse für Development
if (process.env.ANALYZE_BUNDLE === 'true') {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: 'bundle-report.html'
}));
}
// Weitere Optimierungen hinzufügen (erweitert bestehende config)
config.optimization = {
...config.optimization, // Behalte Kotlin/JS Optimierungen
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
}
}
}
};
// Development Server Konfiguration erweitern
if (config.devServer) {
config.devServer = {
...config.devServer,
historyApiFallback: true,
hot: true,
// API Proxy für Backend-Anfragen (Array-Format für moderne Webpack)
proxy: [
{
context: ['/api'],
target: 'http://localhost:8081',
changeOrigin: true,
secure: false,
pathRewrite: { '^/api': '' }
}
]
}
}
@@ -1,9 +1,12 @@
package at.mocode.clients.shared.commonui.components package at.mocode.clients.shared.commonui.components
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
@@ -16,9 +19,15 @@ fun AppScaffold(
}, },
content: @Composable (PaddingValues) -> Unit content: @Composable (PaddingValues) -> Unit
) { ) {
Scaffold( Column(modifier = Modifier.fillMaxSize()) {
topBar = header, Scaffold(
bottomBar = footer, topBar = header,
content = content modifier = Modifier.weight(1f)
) ) {
paddingValues ->
content(paddingValues)
}
footer()
}
} }
+6 -7
View File
@@ -8,17 +8,16 @@ kotlin.daemon.jvmargs=-Xmx3072M -XX:+UseParallelGC -XX:MaxMetaspaceSize=1024M
# Gradle Configuration # Gradle Configuration
org.gradle.jvmargs=-Xmx3072M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" -XX:+UseParallelGC -XX:MaxMetaspaceSize=1024M -XX:+HeapDumpOnOutOfMemoryError -Xshare:off -Djava.awt.headless=true org.gradle.jvmargs=-Xmx3072M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" -XX:+UseParallelGC -XX:MaxMetaspaceSize=1024M -XX:+HeapDumpOnOutOfMemoryError -Xshare:off -Djava.awt.headless=true
org.gradle.configuration-cache=true
org.gradle.parallel=true
org.gradle.caching=true
# org.gradle.configureondemand=true # Deprecated - removed for Gradle 9.0 compatibility
org.gradle.workers.max=8 org.gradle.workers.max=8
org.gradle.vfs.watch=true org.gradle.vfs.watch=true
# Für bessere Performance
# Configuration Cache optimieren - TEMPORÄR DEAKTIVIERT wegen JS-Test Serialisierungsproblemen
org.gradle.configuration-cache=false
org.gradle.configuration-cache.problems=warn
# Browser für Tests konfigurieren - verwende Chrome mit Puppeteer # Build Performance verbessern
#kotlin.js.browser.karma.useChromeHeadless=true org.gradle.parallel=true
org.gradle.caching=true
# Security and Reproducibility # Security and Reproducibility
org.gradle.dependency.verification=lenient org.gradle.dependency.verification=lenient