Add caddy and clean up build

This commit is contained in:
2026-09-10 11:20:46 +02:00
parent 443a7c483a
commit d6cb4078bc
9 changed files with 49 additions and 57 deletions
+6
View File
@@ -0,0 +1,6 @@
:80 {
reverse_proxy localhost:5173
handle /php/* {
reverse_proxy localhost:8000
}
}
+16
View File
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NASLOV</title>
<script defer type="module" src="/vue/main.js"></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
-26
View File
@@ -1,26 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NASLOV</title>
<?php if (getenv('DEV')): ?>
<script type="module" src="http://localhost:5173/@vite/client"></script>
<?php else: ?>
<link href='dist/assets/app.css' rel='stylesheet' type='text/css'>
<?php endif ?>
</head>
<body>
<div id="app"></div>
<?php if (getenv('DEV')): ?>
<script type="module" src="http://localhost:5173/vue/main.js"></script>
<?php else: ?>
<script type="module" src="dist/app.js"></script>
<?php endif ?>
</body>
</html>
+2 -4
View File
@@ -3,10 +3,8 @@
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "vite build",
"build-dev": "vite build --mode development",
"dev": "vite build --mode development --watch",
"serve": "concurrently \"vite\" \"cross-env DEV=1 php -S localhost:8000\" \"mailpit\""
"build": "vite build && cp -R php dist/php",
"serve": "concurrently \"vite\" \"php -S localhost:8000\" \"mailpit\" \"caddy run --config Caddyfile\""
},
"dependencies": {
"@fortawesome/fontawesome-free": "7.3.1",
+5
View File
@@ -0,0 +1,5 @@
<?php
$notifications = ["Helo1", "hello2"];
echo json_encode($notifications);
+2 -20
View File
@@ -4,7 +4,7 @@ import vue from '@vitejs/plugin-vue'
import VueRouter from 'vue-router/vite'
import VueI18n from '@intlify/unplugin-vue-i18n/vite'
export default defineConfig(({ mode }) => ({
export default defineConfig(() => ({
plugins: [
VueI18n({
include: fileURLToPath(new URL('./vue/locales/**', import.meta.url)),
@@ -15,7 +15,6 @@ export default defineConfig(({ mode }) => ({
}),
vue(),
],
base: './',
server: {
port: 5173,
strictPort: true,
@@ -29,24 +28,7 @@ export default defineConfig(({ mode }) => ({
outDir: 'dist',
emptyOutDir: true,
rolldownOptions: {
input: { app: './vue/main.js' },
output: {
entryFileNames: 'app.js',
manualChunks: undefined,
assetFileNames: (asset) => {
const name = asset.names?.[0] ?? '';
if (name.endsWith('.css')) {
return 'assets/app.css';
}
return 'assets/[name]-[hash][extname]';
},
}
input: { index: './index.html' },
}
},
define: {
__VUE_PROD_DEVTOOLS__: mode === 'development' ? 'true' : 'false'
},
esbuild: {
drop: mode === 'development' ? [] : ['console', 'debugger']
}
}))
+8 -4
View File
@@ -1,13 +1,17 @@
<template>
<LanguageSwitcher />
{{ t('app.hello') }}
<RouterView />
<p>
{{ t('app.hello') }}
</p>
<Suspense>
<RouterView />
</Suspense>
</template>
<script setup>
import { useI18n } from 'vue-i18n'
import LanguageSwitcher from '@/components/LanguageSwitcher.vue'
const { t } = useI18n()
const { t } = useI18n();
</script>
+1 -1
View File
@@ -13,7 +13,7 @@ const loadedLocales = new Set()
async function loadLocaleMessages(locale) {
if (!loadedLocales.has(locale)) {
const messages = await import(`../locales/${locale}.json`)
const messages = await import(`./locales/${locale}.json`)
i18n.global.setLocaleMessage(locale, messages.default)
loadedLocales.add(locale)
}
+9 -2
View File
@@ -1,9 +1,16 @@
<template>
{{ t('app.world') }}
<p>{{ t('app.world') }}</p>
<p v-for="value in j">
{{ value }}
</p>
</template>
<script setup>
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const { t } = useI18n();
const res = await fetch("/php/notifications.php")
const j = await res.json();
</script>