Hello guys, Hopefully, I’m using the right channe...
# javascript
p
Hello guys, Hopefully, I’m using the right channel 😄 A few weeks ago, I decided to create my own portfolio website using “kotlin-js” and “ktor”, nevertheless I faced with a problem: ----------------------------------- Project structure: :buildSrc - for dependencies :client - for the views of the websites(pages, extensions and so on) :server - server based on ktor for redirecting on the web. ----------------------------------- Problem description: Without the :server module we can run our website using this shell command:
./gradlew :client:run --continuous
and it will run continuously our website on the localhost. (works fine). But my target is to run it from the server module, usign this shell command:
./gradlew :server:run --continuous
and it runs perfectly but not presenting the page…. ----------------------------------- Possible solution: I would say that I know the root cause: It happens because the server module has no access to the pregenerated file -
"build/distributions/client.js"
. Also I’m trying to copy it with this code in `build.gradle.kts(:server)`:
Copy code
val processResources by tasks.existing(ProcessResources::class)
processResources {
  from(project(":client").tasks.getByName("browserProductionWebpack").path)
//  dependsOn(project(":client").tasks.getByName("browserProductionWebpack")) - also doesn't work...
}
In case someone already faced with this kind of problem, maybe you can help me to figure out the best solution. 😄 Thank you in advance 😄
t
Is there this project on GitHub?
p
@turansky Yes, but is still in the private repository 😀
t
I see
destinationDirectory
in example
p
@turansky Thank you for your advise, but unfortunately it doesn’t work, the cause is: Unresolved reference: destinationDirectory. Although I think so that you’re right, it can be this problem. I will try to investigate how I can gain this. Thx.
j
Well don't they run on the same port?
Or do you mean you have 2 separate modules but you want magically the server module to present your js module?
I have a ktor backend and a js module, there I have to run them simultaneously and assign different ports
p
@Joost Klitsie On the one project I have it the same as you BE(Ktor) and JS running on the different port. But here I want to create it as you told in the second message (magically): It should works, and also @turansky send the tutorial where they also using the same logic as me(Hopefully i didn’t have enough time to go through all tutorial), but for them it works… 😄
j
maybe you can pull in the JS project as a dependency and serve it as a static page?
t
Hot reload for both In example webpack - main
Unresolved reference: destinationDirectory
@Pavel Petkevich which Kotlin version do you use?
p
@turansky - 1.3.72
t
сс @Ilya Goncharov [JB]
i
Seems that you have Kotlin DSL, in sample there is Groovy DSL, which is dynamically typed In Kotlin DSL you have statically typed script, so you need to cast task instance With for example
tasks.withType(KotlinWebpack::class.java).getByName(“browserProductionWebpack”).destinationDirectory
🚀 2
p
@ilya.gorbunov Thank you, man! You saved my day! 🚀🤘🏼 it is already copy the JS file into
build/resources/client.js
😄