https://kotlinlang.org logo
Title
r

Rahul Rawat

02/12/2022, 2:20 PM
Can anyone tell me why the following isn’t working
Img(
                src = "../resources/ic_splash.svg",
                attrs = {
                    style {
                        width(300.px)
                        height(300.px)
                    }
                }
            )
b

Big Chungus

02/12/2022, 2:29 PM
Because it needs a path relative to run directory, not a source file.
r

Rahul Rawat

02/12/2022, 2:33 PM
I am trying web development for the first time so not really sure what run directory is 😅. Can you please point me as how can I make it work?
@Big Chungus ☝️?
b

Big Chungus

02/13/2022, 2:35 PM
Inspect your build output to see where your resources are placed relative to js file generated by the kotlin compiler.
👍 1
r

Rahul Rawat

02/13/2022, 4:17 PM
@Big Chungus So I found the js file named Address.js inside my build folder and made a relative path like so
"../../../../../src/jsMain/resources/ic_splash.svg"
But the image isn’t loading still. Is there anything else I am missing?
b

Big Chungus

02/13/2022, 4:26 PM
Try assuming resources directory to match root url. You should be able to refer to them as "./path/from/resources/folder/to/my-asset.png"