5xry2
07/21/2023, 4:15 PMjsBrowserDevelopmentRun --continuous
+
jvmRun -DmainClass=application.ServerKt --quiet
I added a folder webpack.config.d to the project root and added a 01.devServer.js with the following contents:
;(function (config) {
const shouldRunServer = config.mode !== "production"
const serverUrl = '<http://127.0.0.1:8081>'
if (shouldRunServer) {
config.devServer = config.devServer || {}
config.devServer.proxy = {
'/': {
target: serverUrl,
secure: false,
bypass: function (req, res, proxyOptions) {
if (req.headers.accept.indexOf('.js') !== -1) {
return req.headers.accept;
}
}
}
}
}
})(config);
where my Server.kt looks like
fun main() {
embeddedServer(Netty, port = 8081, host = "127.0.0.1") {
routing {
get("/") {
call.respondHtml(HttpStatusCode.OK, HTML::index)
}
static("/static") {
resources()
}
}
}.start(wait = true)
}
The result is that I get redirected from localhost:8080 to 8081 where my server serves content and I can see in the gradle process window that after a change he updates, but on page reload nothing happens, until I restart the server. So the webpack-dev-server seems to "only" redirect.