Ok I have a stupid question (but I can't find an a...
# javascript
f
Ok I have a stupid question (but I can't find an answer): How can I include a custom stylesheet? I found out that with `
Copy code
js("require('normalize.css/normalize.css')")
I can include a npm packaged stylesheet into my kotlinjs project. But what If I want below that import a custom stylesheet that is specific to this project? I've tried
Copy code
js("require('./style.css')")
as
style.css
is in the
resources
folder but it complains that it can't find that file
r
require("style.css")
f
but it can not find
require
in my codebase do I need to import a library to make it available?
r
define require function as external
Copy code
external fun require(name: String): dynamic
f
But wouldn’t my
Copy code
js("require('./style.css')")
also work? as it will evaluate to the same at the end and webpack should be able to pickup my style file? But I got the error message that the
style.css
was not found
r
perhaps it would
try adding
Copy code
config.resolve.modules.push("../../processedResources/js/main");
to a *.js file in
webpack.config.d
directory
or try this plugin, which afaik automatically configures resources for Kotlin/JS projects: https://github.com/turansky/kfc-plugins
you can also just take one of my KVision sample projects as an example: https://github.com/rjaros/kvision-examples
f
I do have my css configured as listed in the doc. Maybe it just does not work with relative path. Going to try it without the
./
. But its very strange that there official doc references
require
as well but it is not a default external definition for browser projects
t
You can simply add webpack plugin add files from
src/main/resources
folder will be available for
require