Development server and continuous compilation
Instead of manually compiling and running your Kotlin/JS project each time you want to see the changes you made, you can use the continuous compilation mode. Rather than using the regular jsBrowserDevelopmentRun
(for browser
) and jsNodeDevelopmentRun
(for nodejs
) command, invoke the Gradle wrapper in continuous mode:
If you are working in IntelliJ IDEA, you can pass the same flag via the list of run configurations. After running the jsBrowserDevelopmentRun
Gradle task for the first time from the IDE, IntelliJ IDEA automatically generates a run configuration for it, which you can edit at the top toolbar:

Enable continuous mode via the Run/Debug Configurations dialog by adding the --continuous
flag to the arguments for the run configuration:

When executing this run configuration, you can note that the Gradle process continues watching for changes to the program:

Once a change has been detected, the program is recompiled automatically. If you still have the web page open in the browser, the development server triggers an automatic reload of the page, and the changes become visible. This is thanks to the integrated webpack-dev-server
that is managed by the Kotlin Multiplatform Gradle plugin.