Webpack watch in Ktor/Js project

I have project with JVM server and JS client and I use gradle to build it. I noticed that webpack is being used for compiling JS. How can I use webpack watch mod for automatically rebuilding only front-end (React)of my project?

You can try continuous mode.

I don’t understand where should I add continues arg. I don’t use this run process from your link. I have my own run which depends on jsBrowserProductionWebpack.

jvmJar {

task run1(type: JavaExec, dependsOn: [jvmJar]) {


this is how my gradle menu looks, there is no run in other

Can you check ./gradlew run1 --continuous in your terminal? If it doesn’t help can you please attach a link to your project?

I made it work this way:

  1. create directory webpack.config.d at the root of the project
  2. create file wp.js (name does not matter as long as it is a .js file)in it with the following content:
config.watch = true;
  1. run your task with --continuous (shorthand: -t) as @ivan.kubyshkin says should now update the javascript correctly.

@ilya.goncharov @ivan.kubyshkin
KotlinWebpack.kt, doExecute, L232 seems to assume that webpack has watch enabled. Could this be decided through the gradle plugin? After all some of the webpack configuration options such as reporting are configured from the gradle script through the kotlin plugin.

Hope this helps.

I noticed on a fresh checkout of my project that
if config.watch = true in webpack.config.d AND
if the file build/production/<output js file>.js does not exist,
then running ./gradlew build does not create build/production/<output js file>.js.

I had to put config.watch = false to run ./gradlew build and have the files properly created, then switch it back to true to continue developing as usual.