go: /static -> /assets in varnames,routes,dirs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
70ec7f5e53
commit
1655d6b792
6
.gitignore
vendored
6
.gitignore
vendored
@ -4,8 +4,10 @@ pcmt
|
||||
# air tmp dir
|
||||
/tmp
|
||||
|
||||
# static assets folder
|
||||
/static/
|
||||
# this stylesheet gets dynamically rebuilt and is therefore not a stable thing
|
||||
# to stage to git. instead, users are expected to build it before compiling and
|
||||
# running the application.
|
||||
/assets/pcmt.css
|
||||
|
||||
/node_modules/
|
||||
|
||||
|
@ -10,12 +10,12 @@ func (a *App) getAssets(live bool) http.FileSystem {
|
||||
if live {
|
||||
a.logger.Info("assets loaded in live mode")
|
||||
|
||||
return http.FS(os.DirFS("static"))
|
||||
return http.FS(os.DirFS("assets"))
|
||||
}
|
||||
|
||||
a.logger.Info("assets loaded in embed mode")
|
||||
|
||||
fsys, err := fs.Sub(a.embeds.assets, "static")
|
||||
fsys, err := fs.Sub(a.embeds.assets, "assets")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"git.dotya.ml/mirre-mt/pcmt/handlers"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
)
|
||||
|
||||
func (a *App) SetupRoutes() {
|
||||
@ -23,7 +24,15 @@ func (a *App) SetupRoutes() {
|
||||
handlers.InitHandlers(a.version, conf, tmpls)
|
||||
|
||||
// e.GET("/", echo.WrapHandler(assetHandler))
|
||||
e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", assets)))
|
||||
// keep /static/* as a compatibility fallback for /assets.
|
||||
e.GET(
|
||||
"/static/*",
|
||||
nil,
|
||||
middleware.Rewrite(
|
||||
map[string]string{"/static/*": "/assets/$1"},
|
||||
),
|
||||
)
|
||||
e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets)))
|
||||
// e.GET("/", handlers.Index(indexTmpl))
|
||||
// e.GET("/", handlers.Index(conf, tmpls))
|
||||
// e.GET("/", handlers.Index(conf))
|
||||
|
2
bs.js
2
bs.js
@ -17,7 +17,7 @@ module.exports = {
|
||||
"port": 3003
|
||||
},
|
||||
/* "files": true, */
|
||||
"files": ["templates/*.tmpl", "dist/*.css"],
|
||||
"files": ["templates/*.tmpl", "assets/*.css"],
|
||||
"watchEvents": [
|
||||
"change"
|
||||
],
|
||||
|
6
justfile
6
justfile
@ -1,8 +1,7 @@
|
||||
# run tailwindcss tool in watch mode.
|
||||
watch-tw:
|
||||
npm i
|
||||
mkdir -pv static
|
||||
npx tailwindcss -i ./assets/input.css -o ./static/pcmt.css --watch
|
||||
npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --watch
|
||||
|
||||
# start browser-sync.
|
||||
watch-brs:
|
||||
@ -12,8 +11,7 @@ watch-brs:
|
||||
# build app stylesheets using the tailwindcss cli tool.
|
||||
tw:
|
||||
npm i
|
||||
mkdir -p static
|
||||
npx tailwindcss -i ./assets/input.css -o ./static/pcmt.css --minify
|
||||
npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --minify
|
||||
|
||||
# build the application.
|
||||
build:
|
||||
|
Loading…
Reference in New Issue
Block a user