add kvision template
This commit is contained in:
parent
5e69799136
commit
3a33062cd4
15 changed files with 228 additions and 1 deletions
|
|
@ -1,7 +1,60 @@
|
|||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("dev.adamko.factoriowebmap.archetype.base")
|
||||
// kotlin("jvm")
|
||||
id("io.kvision") version "5.4.1"
|
||||
kotlin("js")
|
||||
kotlin("plugin.serialization") version "1.5.31"
|
||||
}
|
||||
|
||||
group = "${rootProject.group}.server"
|
||||
version = rootProject.version
|
||||
|
||||
|
||||
val webDir = file("src/main/web")
|
||||
|
||||
|
||||
val kvisionVersion = "5.4.1"
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
browser {
|
||||
runTask {
|
||||
outputFileName = "main.bundle.js"
|
||||
sourceMaps = false
|
||||
devServer = KotlinWebpackConfig.DevServer(
|
||||
open = false,
|
||||
port = 3000,
|
||||
proxy = mutableMapOf(
|
||||
"/kv/*" to "http://localhost:8080",
|
||||
"/kvws/*" to mapOf("target" to "ws://localhost:8080", "ws" to true)
|
||||
),
|
||||
static = mutableListOf("$buildDir/processedResources/js/main")
|
||||
)
|
||||
}
|
||||
webpackTask {
|
||||
outputFileName = "main.bundle.js"
|
||||
}
|
||||
testTask {
|
||||
useKarma {
|
||||
useChromeHeadless()
|
||||
}
|
||||
}
|
||||
}
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
sourceSets["main"].dependencies {
|
||||
implementation("io.kvision:kvision:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-bootstrap:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-bootstrap-css:$kvisionVersion")
|
||||
implementation("io.kvision:kvision-i18n:$kvisionVersion")
|
||||
}
|
||||
sourceSets["test"].dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
implementation("io.kvision:kvision-testutils:$kvisionVersion")
|
||||
}
|
||||
sourceSets["main"].resources.srcDir(webDir)
|
||||
|
||||
}
|
||||
|
|
|
|||
38
modules/server/src/main/kotlin/com/example/App.kt
Normal file
38
modules/server/src/main/kotlin/com/example/App.kt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package com.example
|
||||
|
||||
import io.kvision.Application
|
||||
import io.kvision.BootstrapCssModule
|
||||
import io.kvision.BootstrapModule
|
||||
import io.kvision.CoreModule
|
||||
import io.kvision.html.div
|
||||
import io.kvision.i18n.DefaultI18nManager
|
||||
import io.kvision.i18n.I18n
|
||||
import io.kvision.i18n.I18n.tr
|
||||
import io.kvision.module
|
||||
import io.kvision.panel.root
|
||||
import io.kvision.require
|
||||
import io.kvision.startApplication
|
||||
|
||||
class App : Application() {
|
||||
init {
|
||||
require("./css/kvapp.css")
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
I18n.manager =
|
||||
DefaultI18nManager(
|
||||
mapOf(
|
||||
"pl" to require("./i18n/messages-pl.json"),
|
||||
"en" to require("./i18n/messages-en.json")
|
||||
)
|
||||
)
|
||||
|
||||
root("kvapp") {
|
||||
div(tr("This is a localized message."))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
startApplication(::App, module.hot, BootstrapModule, BootstrapCssModule, CoreModule)
|
||||
}
|
||||
0
modules/server/src/main/resources/css/kvapp.css
Normal file
0
modules/server/src/main/resources/css/kvapp.css
Normal file
23
modules/server/src/main/resources/i18n/messages-en.po
Normal file
23
modules/server/src/main/resources/i18n/messages-en.po
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the KVision package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: KVision\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-08-18 01:34+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: English\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
|
||||
#: ../src/main/kotlin/com/example/App.kt:20
|
||||
msgid "This is a localized message."
|
||||
msgstr ""
|
||||
23
modules/server/src/main/resources/i18n/messages-pl.po
Normal file
23
modules/server/src/main/resources/i18n/messages-pl.po
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the KVision package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: KVision\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-08-18 01:34+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: Polish\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||
|
||||
#: ../src/main/kotlin/com/example/App.kt:20
|
||||
msgid "This is a localized message."
|
||||
msgstr "To jest przetłumaczona wiadomość."
|
||||
8
modules/server/src/main/resources/i18n/messages.pot
Normal file
8
modules/server/src/main/resources/i18n/messages.pot
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Language: \n"
|
||||
|
||||
#: src/main/kotlin/com/example/App.kt:31
|
||||
msgid "This is a localized message."
|
||||
msgstr ""
|
||||
12
modules/server/src/main/web/index.html
Normal file
12
modules/server/src/main/web/index.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>KVision App</title>
|
||||
<script type="text/javascript" src="main.bundle.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="kvapp"></div>
|
||||
</body>
|
||||
</html>
|
||||
15
modules/server/src/test/kotlin/test/com/example/AppSpec.kt
Normal file
15
modules/server/src/test/kotlin/test/com/example/AppSpec.kt
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package test.com.example
|
||||
|
||||
import io.kvision.test.SimpleSpec
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class AppSpec : SimpleSpec {
|
||||
|
||||
@Test
|
||||
fun render() {
|
||||
run {
|
||||
assertTrue(true, "Dummy test")
|
||||
}
|
||||
}
|
||||
}
|
||||
3
modules/server/webpack.config.d/bootstrap.js
vendored
Normal file
3
modules/server/webpack.config.d/bootstrap.js
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
config.module.rules.push({test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, type: 'asset'});
|
||||
config.module.rules.push({test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, type: 'asset'});
|
||||
config.module.rules.push({test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, type: 'asset/resource'});
|
||||
1
modules/server/webpack.config.d/css.js
Normal file
1
modules/server/webpack.config.d/css.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
config.module.rules.push({ test: /\.css$/, use: ["style-loader", { loader: "css-loader", options: {sourceMap: false} } ] });
|
||||
6
modules/server/webpack.config.d/file.js
Normal file
6
modules/server/webpack.config.d/file.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
config.module.rules.push(
|
||||
{
|
||||
test: /\.(jpe?g|png|gif|svg)$/i,
|
||||
type: 'asset/resource'
|
||||
}
|
||||
);
|
||||
6
modules/server/webpack.config.d/handlebars.js
Normal file
6
modules/server/webpack.config.d/handlebars.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
config.module.rules.push(
|
||||
{
|
||||
test: /\.hbs$/i,
|
||||
loader: 'handlebars-loader'
|
||||
}
|
||||
);
|
||||
9
modules/server/webpack.config.d/jquery.js
vendored
Normal file
9
modules/server/webpack.config.d/jquery.js
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
;(function() {
|
||||
const webpack = require('webpack')
|
||||
|
||||
config.plugins.push(new webpack.ProvidePlugin({
|
||||
$: "jquery",
|
||||
jQuery: "jquery",
|
||||
"window.jQuery": "jquery"
|
||||
}));
|
||||
})();
|
||||
15
modules/server/webpack.config.d/moment.js
Normal file
15
modules/server/webpack.config.d/moment.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
;(function() {
|
||||
const webpack = require('webpack')
|
||||
try {
|
||||
const moment = require("moment");
|
||||
config.plugins.push(new webpack.IgnorePlugin({
|
||||
resourceRegExp: /^\.\/locale$/,
|
||||
contextRegExp: /moment$/,
|
||||
}));
|
||||
config.plugins.push(new webpack.ProvidePlugin({
|
||||
moment: "moment",
|
||||
"window.moment": "moment"
|
||||
}));
|
||||
} catch (e) {
|
||||
}
|
||||
})();
|
||||
15
modules/server/webpack.config.d/webpack.js
Normal file
15
modules/server/webpack.config.d/webpack.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
config.resolve.modules.push("../../processedResources/js/main");
|
||||
|
||||
if (config.devServer) {
|
||||
config.devServer.hot = true;
|
||||
config.devtool = 'eval-cheap-source-map';
|
||||
} else {
|
||||
config.devtool = undefined;
|
||||
}
|
||||
|
||||
// disable bundle size warning
|
||||
config.performance = {
|
||||
assetFilter: function (assetFilename) {
|
||||
return !assetFilename.endsWith('.js');
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue