hi everyone, now I have some trouble on `multiplat...
# multiplatform
k
hi everyone, now I have some trouble on
multiplatform + springboot + react
. The application can’t find the javascript file. I package the
js
file into jar using:
Copy code
tasks.getByName<BootJar>("bootJar") {
    val webpackTask = tasks.getByName<KotlinWebpack>("reactBrowserDevelopmentWebpack")
    dependsOn(webpackTask) // make sure JS gets compiled first
    println(webpackTask.destinationDirectory)
    println(webpackTask.outputFileName)
    from(File(webpackTask.destinationDirectory, webpackTask.outputFileName))
    archiveBaseName.set("${project.name}-with-dependencies")
}
and the jar actually has the
js
file. But when i start the springboot application and visit the index page, it report not found error.
Copy code
@GetMapping("/")
    @ResponseBody
    fun index() = createHTML().html {
        head {
            title("Hello,Kevin")
        }
        body {
            div {
                id = "root"
            }
            script(src = "kotlin-fullstack-v2.js"){}
        }
    }
Is there any fault in my code?
1
i have figured out this issues using
from\into in the bootJar task
copy js files into the target directory:
Copy code
tasks.getByName<BootJar>("bootJar") {
    val webpackTask = tasks.getByName<KotlinWebpack>("reactBrowserDevelopmentWebpack")
    dependsOn(webpackTask) // make sure JS gets compiled first

    from(File(webpackTask.destinationDirectory, webpackTask.outputFileName)){
        into("BOOT-INF/classes/static/js/src")
    }
    archiveBaseName.set("${project.name}-with-dependencies")
    mainClass.set("com.kevin.FullStackApplicationKt")
    archiveClassifier.set("boot")
}