Hello. I went over the tuturial available at <htt...
# javascript
d
Hello. I went over the tuturial available at https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/01_Introduction and after reading it my first exercise was to use one of the components available in the react bootstrap lib (https://react-bootstrap.github.io/getting-started/introduction). I created a
.kt
file for the
Alert
component and everything works fine exept importing the CSS resources. For now I dealt with this by importing the CSS file directly in html but I am wondering what would be the proper way of saying the following:
Copy code
{/* The following line can be included in your src/index.js or App.js file*/}

import 'bootstrap/dist/css/bootstrap.min.css';
r
require("bootstrap/dist/css/bootstrap.min.css")
d
Where does
require
come from? My intellij does not seem to be able to find it. This is what I have so far:
Copy code
@file:JsModule("react-bootstrap")
@file:JsNonModule

import react.*

@JsName("Alert")
external val Alert: RClass<AlertProps>

external interface AlertProps: RProps {
    var variant: String
}
and my
build.gradle.kts
has the following dependencies:
Copy code
implementation(npm("react-bootstrap"))
implementation(npm("bootstrap"))
I think I got it:
Copy code
kotlinext.js.require("")
What would be the preferred place to call it? Doing it in the
main
method raises an error:
Copy code
Uncaught Error: Module parse failed: Unexpected token (6:3)
I just found https://youtrack.jetbrains.com/issue/KT-32721 which seems to be related.
r
I don’t have a ton of time to help, but the error could be related to your build... have you setup webpack to be able to import CSS files?
My memory on this is not great, but it vaguely looks like its trying to parse your CSS as if it were javascript
d
Nope, I have the same setup as in the tutorial. Thanks for the tip. I will dig into this.
r
Hope you figured this out!
d
Yep, it's working. I followed the instructions in https://youtrack.jetbrains.com/issue/KT-32721.
r
Ah yeah, that’s pretty much what I guessed. Good!
👍 1