Robert Jaros
09/05/2025, 12:37 PM/src/**/*.kt
as files being watched. After every kt file change it reloads the application. And then Vite reloads again when compilation is finished. It is similar to this: https://github.com/tailwindlabs/tailwindcss/issues/16764 . Any idea if we can somehow "de-watch" files in vite?Robert Jaros
09/05/2025, 12:48 PMCLOVIS
09/05/2025, 1:27 PMRobert Jaros
09/05/2025, 1:47 PMCLOVIS
09/05/2025, 2:10 PMCLOVIS
09/05/2025, 2:11 PMRobert Jaros
09/05/2025, 2:15 PMserver: {
watch: {
ignored: /.*\.kt/
}
},
Robert Jaros
09/05/2025, 2:16 PMRobert Jaros
09/05/2025, 2:22 PMRobert Jaros
09/05/2025, 2:23 PMCLOVIS
09/05/2025, 2:47 PMCLOVIS
09/05/2025, 2:50 PMRobert Jaros
09/06/2025, 12:59 PM<script>
in the index.html
file like this:
<script type="module">
import './template.mjs';
if (import.meta.hot) {
import.meta.hot.accept('./template.mjs');
}
</script>
This alone makes the dev process a lot faster.Robert Jaros
09/06/2025, 1:00 PMRobert Jaros
09/06/2025, 1:08 PMif (import.meta.hot != null) {
if (import.meta.hot.data.appState != null) {
val restoredState = import.meta.hot.data.appState
// do something with the state, e.g. populate viewModel
}
import.meta.hot.dispose { data ->
val someState = ... // get application state, e.g. from viewModel
data.appState = someState
}
}
Robert Jaros
09/06/2025, 1:13 PMappState
property can have different name (you can also use multiple properties). With js
target you can use `Any`/`dynamic` type and store anything you want. In my framework I only use data serialized to String for compatibility with wasmJs
.Robert Jaros
09/06/2025, 1:15 PMRobert Jaros
09/06/2025, 1:22 PMCLOVIS
09/06/2025, 3:29 PMRobert Jaros
09/06/2025, 3:51 PMCLOVIS
09/06/2025, 4:00 PMRobert Jaros
09/06/2025, 4:04 PMimport.meta.hot
in a library, because it will be different (specific to the library's module). You have to use it directly in the application module. You can also get the reference in the application and pass it to the library code.Robert Jaros
09/06/2025, 4:07 PMRobert Jaros
09/06/2025, 4:08 PM