Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 1.33 KB

README.md

File metadata and controls

50 lines (40 loc) · 1.33 KB

kwp

webpack plugin for resolving modules produced by Kotlin.JS Gradle builds

This comes as Gradle plugin, which adds webpack_loader task to a project, which scans project jar artifacts for generated javascript files as well as Webpack plugin, which declares an alias for each Kotlin module to it resulting javascript output. Webpack plugin is also watching Kotlin sourcefiles and launches Webpack build appropriately.

For example of usage please look at https://github.com/shafirov/kwp-sample

Setting up: First, add repository and buildscript classpath dependency to be able to apply the plugin:

buildscript {
    repositories {
        maven {
            url "https://dl.bintray.com/shafirov/kwp"
        }
    }

    dependencies {
        classpath "org.jetbrains.kwp:kwp:0.1.8"
    }
}

Then for the project you have compileKotlin2Js apply the plugin:

    apply plugin: KWP

This is it for gradle part of setup. Now you need to hook up plugin (that comes with gradle distro) into webpack.config.js

var KotlinWebpackPlugin = require('./build/kwp/kwp')

var webpackConfig = {
  ...
    plugins: [
      new KotlinWebpackPlugin({
        buildFile: './build.gradle',
        project: 'showcase'
      })
    ]

Then you can just require some Kotlin modules:

require('showcase')