Okay, so I did the tutorial on “The State of Kotlin/JS” from the KotlinConf talk.
Everything works pretty good, however I want to deploy a preferably minified file.
I have my index.html in resources and I have my App.kt. When I do ./gradlew build I get the following:
build/js/packages/my-app with a package.json and a webpack.config.js. However, where is my index.html gone and how do I run it in production?
I would’ve expected a package somewhere with the index.html included. I also not that the webpack config is set to ‘development’.
Any idea how to continue?
EDIT: I found my-app.js in build/distributions. That was 13MB. When switching webpack production mode it became 12.5MB. I removed the source-maps and is was 2MB. I guess that makes sense, taking into account it includes React and Kotlin.
However, I suppose this is a setting somewhere as well?
a default “create-react-kotlin-app” app is predefined config, if you want to customize to further you can eject it,
yarn eject
do this command in a copied location, you cannot undo it
once you do that you can find “scripts\build.js” where you can customize the production minimize file set
you can also point to CDN version of kotlin for example
However, during KotlinConf I got the feeling that the way forward was via the Gradle script. The create-react-kotlin-app uses the webpack plugin. It works a lot better, so I think I’ll continue with that.
EDIT: Okay, I am still running into problems.
I thought I could add my kotlin-common library into the project, but that appears to be difficult. The only way I can make this work is by just copying my kt files, which doesn’t make sense at all.
I’ll switch back to the Gradle Multiplatform method and just roll out my own deployment script with webpack.