mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-28 16:45:32 +00:00
added build script + proper differentiation of dev & prod builds
This commit is contained in:
@@ -4,7 +4,7 @@ tmp_dir = "tmp"
|
||||
|
||||
[build]
|
||||
args_bin = []
|
||||
full_bin = "export KGPZ_WATCH=false; ./tmp/main"
|
||||
full_bin = "npm --prefix views/ run build -- --config vite.dev.config.js; export KGPZ_WATCH=false; ./tmp/main"
|
||||
cmd = "go build -tags=\"dev\" -o ./tmp/main ."
|
||||
delay = 400
|
||||
exclude_dir = [
|
||||
@@ -30,7 +30,7 @@ log = "build-errors.log"
|
||||
poll = false
|
||||
poll_interval = 0
|
||||
post_cmd = []
|
||||
pre_cmd = ["npm --prefix views/ run build"]
|
||||
pre_cmd = []
|
||||
rerun = false
|
||||
rerun_delay = 500
|
||||
send_interrupt = true
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
KGPZ/
|
||||
tmp/
|
||||
bin/
|
||||
data_git/
|
||||
cache_geo/
|
||||
cache_gnd/
|
||||
|
||||
12
build.sh
Executable file
12
build.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -rf ./bin
|
||||
npm --prefix ./views run build -- --config vite.config.js
|
||||
mkdir -p ./bin
|
||||
go build -o ./bin/kgpz .
|
||||
if [ -f ./config.json ]; then
|
||||
cp ./config.json bin/config.json
|
||||
else
|
||||
cp ./config.dev.json ./bin/config.json
|
||||
fi
|
||||
|
||||
24
kgpz_web.go
24
kgpz_web.go
@@ -78,6 +78,14 @@ func Start(k *app.KGPZ, s *server.Server, c *providers.ConfigProvider) {
|
||||
// INFO: hot reloading for poor people
|
||||
if c.Watch {
|
||||
go func() {
|
||||
_, routesexist := os.Stat(server.ROUTES_FILEPATH)
|
||||
_, layoutexist := os.Stat(server.LAYOUT_FILEPATH)
|
||||
|
||||
if routesexist != nil && layoutexist != nil {
|
||||
logging.Info("Routes or Layout folder does not exist. Watcher disabled.")
|
||||
return
|
||||
}
|
||||
|
||||
watcher, err := helpers.NewFileWatcher()
|
||||
if err != nil {
|
||||
return
|
||||
@@ -89,14 +97,18 @@ func Start(k *app.KGPZ, s *server.Server, c *providers.ConfigProvider) {
|
||||
s.Engine(Engine(k, c))
|
||||
})
|
||||
|
||||
err = watcher.RecursiveDir(server.ROUTES_FILEPATH)
|
||||
if err != nil {
|
||||
return
|
||||
if routesexist != nil {
|
||||
err = watcher.RecursiveDir(server.ROUTES_FILEPATH)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err = watcher.RecursiveDir(server.LAYOUT_FILEPATH)
|
||||
if err != nil {
|
||||
return
|
||||
if layoutexist != nil {
|
||||
err = watcher.RecursiveDir(server.LAYOUT_FILEPATH)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -1,31 +1,22 @@
|
||||
function setup() {
|
||||
let templates = document.querySelectorAll("template[simple]");
|
||||
templates.forEach((template) => {
|
||||
let templateId = template.getAttribute("id");
|
||||
let templateContent = template.content;
|
||||
customElements.define(templateId, class extends HTMLElement {
|
||||
function a() {
|
||||
document.querySelectorAll("template[simple]").forEach((l) => {
|
||||
let s = l.getAttribute("id"), n = l.content;
|
||||
customElements.define(s, class extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.appendChild(templateContent.cloneNode(true));
|
||||
this.slots = this.querySelectorAll("slot");
|
||||
super(), this.appendChild(n.cloneNode(!0)), this.slots = this.querySelectorAll("slot");
|
||||
}
|
||||
connectedCallback() {
|
||||
let toremove = [];
|
||||
this.slots.forEach((tslot) => {
|
||||
let slotName = tslot.getAttribute("name");
|
||||
let slotContent = this.querySelector(`[slot="${slotName}"]`);
|
||||
if (slotContent) {
|
||||
tslot.replaceWith(slotContent.cloneNode(true));
|
||||
toremove.push(slotContent);
|
||||
}
|
||||
});
|
||||
toremove.forEach((element) => {
|
||||
element.remove();
|
||||
let o = [];
|
||||
this.slots.forEach((e) => {
|
||||
let r = e.getAttribute("name"), t = this.querySelector(`[slot="${r}"]`);
|
||||
t && (e.replaceWith(t.cloneNode(!0)), o.push(t));
|
||||
}), o.forEach((e) => {
|
||||
e.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
export {
|
||||
setup
|
||||
a as setup
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -26,7 +26,7 @@
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="w-full h-full" hx-ext="response-targets">
|
||||
<body class="w-full h-full p-3" hx-ext="response-targets">
|
||||
{{ block "_menu" . }}
|
||||
<!-- Default app menu... -->
|
||||
{{ end }}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export default {
|
||||
plugins: {
|
||||
'postcss-import': {},
|
||||
'tailwindcss/nesting': {},
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
plugins: {
|
||||
"postcss-import": {},
|
||||
"tailwindcss/nesting": {},
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="py-3">
|
||||
<div class="py-3 text-xl">
|
||||
<div>{{ $model.Year }}</div>
|
||||
<div>Stück {{ $model.No }}</div>
|
||||
<div>{{ $model.Day }}. {{ $date.Month }} ({{ $date.Weekday }})</div>
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import { resolve } from "path";
|
||||
import { defineConfig } from "vite";
|
||||
export default defineConfig({
|
||||
mode: "production",
|
||||
build: {
|
||||
root: resolve(__dirname, ""),
|
||||
// These are dev options only:
|
||||
minify: false,
|
||||
emitAssets: true,
|
||||
|
||||
lib: {
|
||||
entry: "./transform/main.js",
|
||||
name: "PC-UI",
|
||||
|
||||
27
views/vite.dev.config.js
Normal file
27
views/vite.dev.config.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { resolve } from "path";
|
||||
import { defineConfig } from "vite";
|
||||
import tailwindcss from "tailwindcss";
|
||||
|
||||
export default defineConfig({
|
||||
mode: "development",
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: [tailwindcss],
|
||||
},
|
||||
},
|
||||
build: {
|
||||
root: resolve(__dirname, ""),
|
||||
// These are dev options only:
|
||||
minify: false,
|
||||
emitAssets: true,
|
||||
|
||||
lib: {
|
||||
entry: "./transform/main.js",
|
||||
name: "PC-UI",
|
||||
fileName: "scripts",
|
||||
cssFileName: "style",
|
||||
formats: ["es"],
|
||||
},
|
||||
outDir: resolve(__dirname, "assets/"),
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user