Kotlin dce and css in 1.3.70

I try to convert my custom js toolchain (hand written package.json and webpack.config.js) to the “automated” one from kotlinjs gradle plugin.

Currently DCE complains about my css (I included my css via webpack style-loader). The error message is:

ERROR in ./kotlin-dce/main.js
Module not found: Error: Can’t resolve ‘style.css’ in ‘/build/js/packages/konfiguratorjs/kotlin-dce’
@ ./kotlin-dce/main.js 5676:4-24
@ multi ./kotlin-dce/main.js

Can I somehow tell dce to leave this css thing alone? Is this a known issue? What can I do about this?

Hi! Can you attach a link to your project?

Hi Ivan

To demonstrate this problem I did the following: Generate a project with intellij Gradle / Kotllin Js. In the main.kt add the following code:

 js("require('style.css');")

With an existing style.css file next to main.kt it (for good messure)

If you now run the browserDistribution task it will generate the following error:

ERROR in ./kotlin-dce/KotlinJs1.3.70.js
Module not found: Error: Can't resolve 'style.css' in '<PROJECT>/build/js/packages/KotlinJs1.3.70    /kotlin-dce'
 @ ./kotlin-dce/KotlinJs1.3.70.js 4:4-24
 @ multi ./kotlin-dce/KotlinJs1.3.70.js // Name of the project

If you’d like I could upload the project to github…

1 Like

Try to add to webpack.config.d/css.js:

config.resolve.modules.push("processedResources/Js/main");

config.module.rules.push({
    test: /\.css$/,
    use: [
        "css-loader" // translates CSS into CommonJS
    ]
});

Hi Ivan

Thanks for your reply. I tried your idea, but it didn’t work. I’ve uploaded my test project to github: GitHub - nimloth05/KotlinJs1.3.70 Maybe I did something wrong?

Thanks for your assistance

You should move your style.css to src/main/resources and add implementation npm("css-loader") as a dependency to your build.gradle.

Hi Ivan

Thanks a lot! The DCE error message is gone, so the demo is now running but except the body color is not red. /-:

Edit:
I fixed this problem as well by changing webpack.config.d/css.js line

use: [
        "css-loader" // translates CSS into CommonJS
    ]

to

loader: 'style-loader!css-loader'

and adding line implementation npm("style-loader") in build.gradle

1 Like