With kotlin-styled the following ```val x by css {...
# javascript
a
With kotlin-styled the following
Copy code
val x by css {
  backgroundImage = require("src/main/resources/image.png")
}
gives an error
Copy code
Module 'src/main/resources/image.png' not found
Moving file to main/kotlin/... and changing to relative path from the source file dir gives the same "not found" error. Using JsModule gives the same error too. Where should resources be placed, and how to reference them by relative path in kotlin/js react app? Please, help! Google gives only 2-year (and more) old advices which don't help, because kotlin/js seems to have changed much recently.
a
require("image.png")
a
Even I have the same doubt, referencing via resources does not work..
a
@andylamax, tried, doesn't work either.
Copy code
Module 'image.png' not found
The image file resides both in
resources
, and in sources near .kt file. Neither helps.
a
do you have webpack setup correctly? you should have seen a different error about loaders. Also, it just have to reside in
resources
it doesn't work near
.kt
a
I managed to add resources to module search path, and possibly to load PNG through file-loader. But the overall result is fail 🙂 It is not converted to anything PNG-like. Like reachable relative url or data url (like create-react-app does). I guess I do smth basically wrong...
kotlin-styled
package attracts me with its type-safe approach and Kotlin DSL way, but possibly I should start with simple CSS usage, and with learning webpack... Before create-react-app handled all this magic smoothly. :)