kotlin-hands-on / web-app-react-kotlin-js-gradle

https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/
136 stars 115 forks source link

Running without <script> tag in index.html #9

Closed ganeshramc closed 3 years ago

ganeshramc commented 3 years ago

Hi,

I cloned the project and I'm trying to understand the meaning of this line https://github.com/kotlin-hands-on/web-app-react-kotlin-js-gradle/blob/15afabf83e3dc339a6da0d3d3a4e64429a7d88d9/src/main/resources/index.html#L9

I see the script tag which says confexplorer.js but there is no confexplorer.js. If I try to put it above the "root" div or remove it, my webpage doesn't load. So I'm not sure what that is.

SebastianAigner commented 3 years ago

Hi @ganeshramc!

I've tried to make the description in the hands-on more clear based on your feedback.

As you can see, we're embedding a JavaScript file called confexplorer.js. This is because the Kotlin/JS Gradle plugin will bundle all of our code and its dependencies into a single JavaScript file, which has the same name as our project. (That also means that if you're working in a project you've named followingAlong, you need to make sure to embed followingAlong.js instead.)

As is typical JavaScript convention, we first load the content of our body (including the #root div), and then finally load our scripts, to ensure that all page elements we need have already been loaded by the browser.

https://github.com/kotlin-hands-on/hands-on/blob/master/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/02_Setting_up.md#html-page

I hope this helps. If you have any follow-up questions, please feel free to log another issue! 🎉