Kotlin / kotlin-frontend-plugin

Gradle Kotlin (http://kotlinlang.org) plugin for frontend development
Apache License 2.0
561 stars 69 forks source link

backend-frontend code sharing #115

Open bennylut opened 5 years ago

bennylut commented 5 years ago

Hi, I would like to know if there is any documentation about using this plugin for a full stack application with code that is shared between the server and client? (essentially models, validation logic, utility functions, etc.)

BTW If there is so - I would like to suggest updating the full-stack-example to include such sharing.

wem commented 5 years ago

Afaik there is no documentation at the moment. But only few steps are needed.

  1. Create Multiplatform project https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-a-multiplatform-project
  2. Implement your platform specific / inter-platform code
  3. Add this multiplatform project as dependency to your project with the Kotlin frontend plugin defined (on the previous multiplatform layout your dependency must point to the js part project)

Now you should be able to use the JS part of your multiplatform project within the frontend project.

ideaBlender commented 5 years ago

when I do this, everything works fine until I add "webpackConfigFile = "webpack.config.js" to my webpack bundle. Once I do that it fails to recognize my package structure... com.foo, foo is unrecognized