I just created a new project in IntelliJ: :kotlinn...
# multiplatform
e
I just created a new project in IntelliJ: K Multiplatform -> Full-Stack Web Application -> Next -> Finish -> Wait for project to open, and now what? There is a run configuration 'Run' that runs the server by running Gradle task
run
, but it doesn't start the browser; I have to go to localhost:8080 manually. This is unlike what would happen in a regular Kotlin/JS project, where you run task
browserDevelopmentRun --continuous
. So I tried running
jsBrowserDevelopmentRun
but that doesn't start the server and instead it runs a web page that lists all kinds of .js and .map files that are probably found on localhost:8080, but there is not index.html file because the server isn't running. What's the best practice when doing JVM server + JS frontend multiplatform development to run both server and frontend continuously, and open the browser from the Gradle task pointing at the correct page?
r
If your
index.html
is generated/served only by the ktor backend, you can add a "dummy"
index.html
in your js sourceset resources. This way you will be able to run both webpack dev server (
jsBrowserDevelopmentRun
) for frontend development and the ktor backend for server development (with two separate gradle processes from two different consoles). Additionally you can configure webpack to proxy your API calls to the backend endpoints. With some luck you can have hot-reload working on both sides.
e
Ah, two separate gradle processes! That might be a great idea, for build speed on any changes in the target-specific source.
Thanks a lot Robert
e
I've tested sometime ago but I didn't find it very useful. I don't remember exactly but I think you have to launch a 3rd Gradle task "gradlew -t build -x test -i". It compiles every change in source code, and then the ktor detects it and publish the changes.
u
Thanks for your input. In the end I decided to build my own gradle files and not use the automatically generated ones + looked into webpack more in detail and afterwards it worked.