Improve routing for public files
This commit is contained in:
parent
fd294a00af
commit
e139f746bc
7 changed files with 16 additions and 10 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,3 @@
|
||||||
.qlot
|
.qlot
|
||||||
node_modules
|
node_modules
|
||||||
static/style/tailwind.css
|
|
||||||
.vscode/alive
|
|
||||||
dist
|
dist
|
||||||
|
|
14
src/app.lisp
14
src/app.lisp
|
@ -17,13 +17,19 @@
|
||||||
|
|
||||||
(update-routes)
|
(update-routes)
|
||||||
|
|
||||||
|
(defun exist-public-file-p (path)
|
||||||
|
(and (not (string= path "/"))
|
||||||
|
(let ((pathname (probe-file (concatenate 'string "public" path))))
|
||||||
|
(and pathname
|
||||||
|
(pathname-name pathname)))))
|
||||||
|
|
||||||
(defparameter *app*
|
(defparameter *app*
|
||||||
(lack:builder :accesslog
|
(lack:builder :accesslog
|
||||||
(:static
|
(:static
|
||||||
:path "/assets/"
|
:path (lambda (path)
|
||||||
:root (asdf:system-relative-pathname :hp "dist/assets/"))
|
(if (exist-public-file-p path)
|
||||||
(:static
|
path
|
||||||
:path "/public/"
|
nil))
|
||||||
:root (asdf:system-relative-pathname :hp "public/"))
|
:root (asdf:system-relative-pathname :hp "public/"))
|
||||||
*raw-app*))
|
*raw-app*))
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
(head
|
(head
|
||||||
(title "skyizwhite.dev")
|
(title "skyizwhite.dev")
|
||||||
(script :type "module" :src "http://localhost:5173/@vite/client")
|
(script :type "module" :src "http://localhost:5173/@vite/client")
|
||||||
(script :type "module" :src "http://localhost:5173/src/js/main.js"))
|
(script :type "module" :src "http://localhost:5173/src/assets/main.js"))
|
||||||
(body :class "h-[100svh] w-screen"
|
(body :class "h-[100svh] w-screen"
|
||||||
(main :class "h-full"
|
(main :class "h-full"
|
||||||
pi:children)))))
|
pi:children)))))
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
(div :class "flex flex-col items-center gap-2"
|
(div :class "flex flex-col items-center gap-2"
|
||||||
(div :class "avatar"
|
(div :class "avatar"
|
||||||
(div :class "w-32 mask mask-squircle"
|
(div :class "w-32 mask mask-squircle"
|
||||||
(img :src "/public/img/me.jpg")))
|
(img :src "/img/me.jpg")))
|
||||||
(p :class "text-primary text-3xl text-center"
|
(p :class "text-primary text-3xl text-center"
|
||||||
"Hello, World!"))))))
|
"Hello, World!"))))))
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,11 @@ import { defineConfig } from 'vite'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
build: {
|
build: {
|
||||||
manifest: true,
|
outDir: 'public',
|
||||||
|
emptyOutDir: false,
|
||||||
|
copyPublicDir: false,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: 'src/js/main.js',
|
input: 'src/assets/main.js',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue