diff --git a/client/build.gradle.kts b/client/build.gradle.kts index dc6a973c..45a74e04 100644 --- a/client/build.gradle.kts +++ b/client/build.gradle.kts @@ -106,6 +106,11 @@ kotlin { args.add("--mode=production") args.add("--optimization-minimize") } + runTask { + // Development optimizations for WASM + args.add("--mode=development") + // Dev server settings handled by webpack.config.d/dev-server.js + } } // WASM-specific compiler optimizations for smaller bundles diff --git a/client/src/jsMain/resources/index.html b/client/src/jsMain/resources/index.html index 9c5ce286..9f5978e3 100644 --- a/client/src/jsMain/resources/index.html +++ b/client/src/jsMain/resources/index.html @@ -8,6 +8,10 @@
+ + + + diff --git a/client/src/wasmJsMain/kotlin/at/mocode/ApiConfig.wasmJs.kt b/client/src/wasmJsMain/kotlin/at/mocode/ApiConfig.wasmJs.kt index 57ccb796..b3ff94dd 100644 --- a/client/src/wasmJsMain/kotlin/at/mocode/ApiConfig.wasmJs.kt +++ b/client/src/wasmJsMain/kotlin/at/mocode/ApiConfig.wasmJs.kt @@ -1,6 +1,6 @@ package at.mocode actual object ApiConfig { - actual val baseUrl: String = "" // Same-origin für Nginx-Proxy + actual val baseUrl: String = "" // Same-origin für Nginx-Proxy actual val pingEndpoint: String = "/api/ping" } diff --git a/client/src/wasmJsMain/resources/index.html b/client/src/wasmJsMain/resources/index.html index 5f254fb5..e10092b7 100644 --- a/client/src/wasmJsMain/resources/index.html +++ b/client/src/wasmJsMain/resources/index.html @@ -8,6 +8,10 @@ + + + + diff --git a/client/webpack.config.d/dev-server.js b/client/webpack.config.d/dev-server.js new file mode 100644 index 00000000..40340978 --- /dev/null +++ b/client/webpack.config.d/dev-server.js @@ -0,0 +1,47 @@ +// Development server configuration with API proxy +// This forwards API requests from webpack-dev-server to the gateway + +if (config.mode !== 'production') { + config.devServer = { + ...config.devServer, + + // Proxy API requests to the gateway - using modern object syntax + proxy: { + '/api/**': { + target: 'http://localhost:8081', + changeOrigin: true, + secure: false, + logLevel: 'debug', + pathRewrite: { + '^/api': '/api' // Keep the /api prefix for gateway routing + } + } + }, + + // Disable all caches as requested in previous issue + headers: { + 'Cache-Control': 'no-cache, no-store, must-revalidate', + 'Pragma': 'no-cache', + 'Expires': '0' + }, + + // Development middleware settings + devMiddleware: { + writeToDisk: false, + stats: 'minimal' + }, + + // Static files configuration + static: { + directory: 'src/commonMain/resources', + serveIndex: true, + watch: true + }, + + // CORS settings for development + allowedHosts: 'all', + historyApiFallback: true, + hot: true, + liveReload: true + }; +} diff --git a/client/webpack.config.d/wasm-optimization.js b/client/webpack.config.d/wasm-optimization.js index 5fc0b095..fee9609a 100644 --- a/client/webpack.config.d/wasm-optimization.js +++ b/client/webpack.config.d/wasm-optimization.js @@ -57,8 +57,8 @@ config.optimization = { } }, - // Minimize bundle size - minimize: true + // Minimize bundle size - conditional based on mode + minimize: config.mode === 'production' // Note: minimizer is automatically configured by Kotlin/JS };