From f88c59c04d9f7053a8a97b0c65a282f961913f1b Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Wed, 21 Feb 2018 12:40:10 +0100 Subject: Build size optimizations. --- build.gradle | 16 +++++- npm.dependencies | 22 ++------ src/main/kotlin/pl/treksoft/kvision/KVManager.kt | 68 +++++++++++++++++------- 3 files changed, 68 insertions(+), 38 deletions(-) diff --git a/build.gradle b/build.gradle index 42465be0..43664eb1 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ apply plugin: "io.gitlab.arturbosch.detekt" apply plugin: 'org.jetbrains.dokka' group = 'pl.treksoft' -version = '0.0.3' +version = '0.0.4' repositories { jcenter() @@ -58,6 +58,20 @@ dependencies { kotlinFrontend { npm { + dependency("css-loader") + dependency("style-loader") + dependency("less") + dependency("less-loader") + dependency("imports-loader") + dependency("uglifyjs-webpack-plugin") + dependency("file-loader") + dependency("url-loader") + dependency("jquery", "3.3.1") + dependency("fecha", "2.3.2") + dependency("snabbdom", "0.6.9") + dependency("snabbdom-virtualize", "0.7.0") + dependency("navigo", "7.0.0") + dependency("jquery-resizable-dom", "0.26.0") npmdeps.eachLine { line -> def (name, version) = line.tokenize(" ") dependency(name, version) diff --git a/npm.dependencies b/npm.dependencies index 50a8bb4e..b3b472fb 100644 --- a/npm.dependencies +++ b/npm.dependencies @@ -1,24 +1,10 @@ -css-loader * -style-loader * -less * -less-loader * -imports-loader * -uglifyjs-webpack-plugin * -file-loader * -url-loader * -jquery 3.3.1 bootstrap 3.3.7 bootstrap-webpack 0.0.6 -font-awesome 4.7.0 -font-awesome-webpack 0.0.5-beta.2 -awesome-bootstrap-checkbox 0.3.7 bootstrap-select 1.12.4 ajax-bootstrap-select 1.4.3 -trix 0.11.1 -fecha 2.3.2 bootstrap-datetime-picker 2.4.4 bootstrap-touchspin 3.1.1 -snabbdom 0.6.9 -snabbdom-virtualize 0.7.0 -navigo 7.0.0 -jquery-resizable-dom 0.26.0 +font-awesome 4.7.0 +font-awesome-webpack 0.0.5-beta.2 +awesome-bootstrap-checkbox 0.3.7 +trix 0.11.1 diff --git a/src/main/kotlin/pl/treksoft/kvision/KVManager.kt b/src/main/kotlin/pl/treksoft/kvision/KVManager.kt index b60764df..f0438232 100644 --- a/src/main/kotlin/pl/treksoft/kvision/KVManager.kt +++ b/src/main/kotlin/pl/treksoft/kvision/KVManager.kt @@ -45,37 +45,67 @@ internal object KVManager { internal const val AJAX_REQUEST_DELAY = 300 internal const val KVNULL = "#kvnull" - @Suppress("UnsafeCastFromDynamic") - private val bootstrapWebpack = if (js("typeof KV_NO_BOOTSTRAP_CSS !== 'undefined'")) { - require("bootstrap-webpack!./js/bootstrap.config.js") - } else { + private val bootstrapWebpack = try { require("bootstrap-webpack") + } catch (e: Throwable) { } - private val fontAwesomeWebpack = require("font-awesome-webpack") - private val resizable = require("jquery-resizable-dom") - private val awesomeBootstrapCheckbox = require("awesome-bootstrap-checkbox") - private val bootstrapSelectCss = + private val fontAwesomeWebpack = try { + require("font-awesome-webpack") + } catch (e: Throwable) { + } + private val awesomeBootstrapCheckbox = try { + require("awesome-bootstrap-checkbox") + } catch (e: Throwable) { + } + private val bootstrapSelectCss = try { require("bootstrap-select/dist/css/bootstrap-select.min.css") - private val bootstrapSelect = require("bootstrap-select") - private val bootstrapSelectI18n = require("./js/bootstrap-select-i18n.min.js") - private val bootstrapSelectAjaxCss = + } catch (e: Throwable) { + } + private val bootstrapSelect = try { + require("bootstrap-select/dist/js/bootstrap-select.min.js") + } catch (e: Throwable) { + } + private val bootstrapSelectI18n = try { + require("./js/bootstrap-select-i18n.min.js") + } catch (e: Throwable) { + } + private val bootstrapSelectAjaxCss = try { require("ajax-bootstrap-select/dist/css/ajax-bootstrap-select.min.css") - private val bootstrapSelectAjax = + } catch (e: Throwable) { + } + private val bootstrapSelectAjax = try { require("ajax-bootstrap-select/dist/js/ajax-bootstrap-select.min.js") + } catch (e: Throwable) { + } // private val bootstrapSelectAjaxI18n = // require("ajax-bootstrap-select/dist/js/locale/ajax-bootstrap-select.pl-PL.min.js") - private val trixCss = require("trix/dist/trix.css") - private val trix = require("trix") - private val bootstrapDateTimePickerCss = + private val trixCss = try { + require("trix/dist/trix.css") + } catch (e: Throwable) { + } + private val trix = try { + require("trix") + } catch (e: Throwable) { + } + private val bootstrapDateTimePickerCss = try { require("bootstrap-datetime-picker/css/bootstrap-datetimepicker.min.css") - private val bootstrapDateTimePicker = + } catch (e: Throwable) { + } + private val bootstrapDateTimePicker = try { require("bootstrap-datetime-picker/js/bootstrap-datetimepicker.min.js") - private val bootstrapTouchspinCss = + } catch (e: Throwable) { + } + private val bootstrapTouchspinCss = try { require("bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.css") - private val bootstrapTouchspin = + } catch (e: Throwable) { + } + private val bootstrapTouchspin = try { require("bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js") - internal val fecha = require("fecha") + } catch (e: Throwable) { + } + private val resizable = require("jquery-resizable-dom") + internal val fecha = require("fecha") private val sdPatch = Snabbdom.init( arrayOf( classModule, attributesModule, propsModule, styleModule, -- cgit