Has anyone managed to get new js plugin working wi...
# javascript
b
Has anyone managed to get new js plugin working with dce?
s
FWIW, I was trying to get it to work a while back, under 1.3.41. I can't find the thread to link it, but someone told me to sub-project all the npm dependencies to get it to work. That did make it work, but it was a workaround and sometimes still failed. I have not tried again since.
b
I think a more "elegant" hack would be to copy min-js folder into main js compilation folder before bundling
But it's still a hack ;/
s
I'd have to get my head back into the problem to comment intelligently, but agreed about it being another hack. I came to the conclusion kotlin/js is still in beta until they get the plugin finalized. So for me no tests and no production builds until then. If you figure a way to get continuous karam tests working without browser relaunch or dce to work consistently please drop me a line if you think of it.
b
Here'show I've managed to hack DCE + new MPP js. I'm using webDir as "static" directory, whereas usual resource dir is kept for webpack resources (i.e. css that'll be inlined)
💪🏻 1
🎉 2
👍 8
runnin
./gradlew jsBrowserWebpack -Pprod
produces minified DCE'd bundle with all static files from
webDir
at
build/distributions
s
Thank you for sharing that! Good stuff
s
@Big Chungus I'd also recommend a demo of using dev dependencies to configure Webpack with additional plugins from the
KotlinJsCompilation
block. For example, mine looks like the following:
Copy code
kotlin {
    targets {
        js {
            val main by compilations.getting {
                packageJson {
                    devDependencies += arrayOf(
                        "webpack-merge" to "4.2.2",
                        "terser-webpack-plugin" to "2.0.1",
                        "html-webpack-plugin" to "3.2.0",
                        "html-webpack-template" to "6.2.0",
                        "file-loader" to "4.2.0",
                        "style-loader" to "1.0.0",
                        "css-loader" to "3.2.0",
                        "mini-css-extract-plugin" to "0.8.0",
                        "style-ext-html-webpack-plugin" to "4.1.2",
                        "corejs-upgrade-webpack-plugin" to "2.2.0"
                    )
                }
            }
        }
    }
}