Is it possible to package `resources` inside a Kot...
# javascript
e
Is it possible to package
resources
inside a Kotlin/JS library, making them accessible to dependents? I'm not having much luck finding docs on the subject.
b
They're packaged into klib automatically
To expose them to your consumer you need to leave some kt breadcrumbs Given src/jsMain/resources/my.css Leave this in your kt sources @JsModule("my.css") external val myCSS: dynamic
e
oh! nice I'll try that out, thank you!
yeah not having much luck so far, but I'll keep trying.
t
@Big Chungus I'm trying follow your advice but it doesn't seem to work for me. I'm probably doing something wrong. Original suggestion didn't work at all. I made progress with
Copy code
@JsModule("./asset/css/my.css")
external val cssFile: dynamic
but it looks like kotlin is trying to parse CSS file as I'm getting
Copy code
Module parse failed: Unexpected character '@' (3:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See <https://webpack.js.org/concepts#loaders>
| /* fonts import */
| 
> @import url('<https://fonts.googleapis.com/css2?family=Montserrat:wght@200;400;500;700&display=swap>');
| @import url('<https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;600;700&display=swap>');
| /* This CSS describes common and mobile UI. To see desktop specific CSS, please scroll down to
I made more progress with
@file:JsModule("./asset/css/mycss.css")
in empty file but still it is not perfect.
b
You need to enable css support in kotlin gradle plugin
should be in kotlin.js().browser {} block
t
Ok, thanks. I'll look at it. Is it something like
Copy code
browser {
       runTask {
           devServer = KotlinWebpackConfig.DevServer(
               ...
           )
       }
    }
?
b
No, there should be explicit flag for it.
t
OK, I'll look.
cssSupport.enabled = true
t
Great. Thanks a lot for your help.
b
Tbh I wish it would be enabled by default. It doesn't hurt even if you don't use css...
168 Views