go: redo asset handling
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
* only embed substructure of assets * create subfolders for css, imgs * add .gitattributes file specifying pcmt.css as generated (by tailwind)
This commit is contained in:
parent
1b2679ad97
commit
df0c280ad1
@ -47,7 +47,7 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- pacman -Sy && pacman -S --noconfirm --needed npm
|
- pacman -Sy && pacman -S --noconfirm --needed npm
|
||||||
- npm i
|
- npm i
|
||||||
- npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --minify
|
- npx tailwindcss -i ./assets/input/css/tailwind.css -o ./assets/public/css/pcmt.css --minify
|
||||||
|
|
||||||
- name: go build
|
- name: go build
|
||||||
image: docker.io/immawanderer/archlinux-go:linux-amd64
|
image: docker.io/immawanderer/archlinux-go:linux-amd64
|
||||||
@ -119,7 +119,7 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- apk update -q && apk add -q --no-cache npm
|
- apk update -q && apk add -q --no-cache npm
|
||||||
- npm i
|
- npm i
|
||||||
- npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --minify
|
- npx tailwindcss -i ./assets/input/css/tailwind.css -o ./assets/public/css/pcmt.css --minify
|
||||||
|
|
||||||
- name: go build
|
- name: go build
|
||||||
image: docker.io/library/golang:1.20.4-alpine3.17
|
image: docker.io/library/golang:1.20.4-alpine3.17
|
||||||
|
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
/assets/public/css/pcmt.css linguist-generated
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,8 +9,8 @@ pcmt
|
|||||||
|
|
||||||
# this stylesheet gets dynamically rebuilt and is therefore not a stable thing
|
# 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
|
# to stage to git. instead, users are expected to build it before compiling and
|
||||||
# running the application.
|
# running the application, using either go generate or directly using npm.
|
||||||
/assets/pcmt.css
|
/assets/public/css/pcmt.css
|
||||||
|
|
||||||
/node_modules/
|
/node_modules/
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@ func (a *App) Init(s *settings.Settings, logger *slogging.Logger, dbclient *ent.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if a.assetsPath == "" {
|
if a.assetsPath == "" {
|
||||||
a.assetsPath = "assets"
|
a.logger.Debug("setting assets path as unset")
|
||||||
|
a.assetsPath = "assets/public"
|
||||||
a.setting.SetAssetsPath("assets")
|
a.setting.SetAssetsPath("assets")
|
||||||
} else {
|
} else {
|
||||||
a.setting.SetAssetsPath(a.assetsPath)
|
a.setting.SetAssetsPath(a.assetsPath)
|
||||||
|
@ -29,7 +29,7 @@ func (a *App) getAssets() http.FileSystem {
|
|||||||
|
|
||||||
a.logger.Info("assets loaded in embed mode")
|
a.logger.Info("assets loaded in embed mode")
|
||||||
|
|
||||||
fsys, err := fs.Sub(a.embeds.assets, "assets")
|
fsys, err := fs.Sub(a.embeds.assets, "assets/public")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ func TestStaticRoute(t *testing.T) {
|
|||||||
setting := settings.New()
|
setting := settings.New()
|
||||||
a := &App{
|
a := &App{
|
||||||
templatesPath: "../templates",
|
templatesPath: "../templates",
|
||||||
assetsPath: "../assets",
|
assetsPath: "../assets/public",
|
||||||
}
|
}
|
||||||
log := slogging.Init(false)
|
log := slogging.Init(false)
|
||||||
tstRoute := "/static/"
|
tstRoute := "/static/"
|
||||||
@ -93,7 +93,7 @@ func BenchmarkStatic(b *testing.B) {
|
|||||||
setting := settings.New()
|
setting := settings.New()
|
||||||
a := &App{
|
a := &App{
|
||||||
templatesPath: "../templates",
|
templatesPath: "../templates",
|
||||||
assetsPath: "../assets",
|
assetsPath: "../assets/public",
|
||||||
}
|
}
|
||||||
log := slogging.Init(false)
|
log := slogging.Init(false)
|
||||||
db := enttest.Open(b, "sqlite3", connstr)
|
db := enttest.Open(b, "sqlite3", connstr)
|
||||||
@ -125,7 +125,7 @@ func BenchmarkStatic2(b *testing.B) {
|
|||||||
setting := settings.New()
|
setting := settings.New()
|
||||||
a := &App{
|
a := &App{
|
||||||
templatesPath: "../templates",
|
templatesPath: "../templates",
|
||||||
assetsPath: "../assets",
|
assetsPath: "../assets/public",
|
||||||
}
|
}
|
||||||
log := slogging.Init(false)
|
log := slogging.Init(false)
|
||||||
db := enttest.Open(b, "sqlite3", connstr)
|
db := enttest.Open(b, "sqlite3", connstr)
|
||||||
|
Before Width: | Height: | Size: 339 B After Width: | Height: | Size: 339 B |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 339 B After Width: | Height: | Size: 339 B |
2
bs.js
2
bs.js
@ -17,7 +17,7 @@ module.exports = {
|
|||||||
"port": 3003
|
"port": 3003
|
||||||
},
|
},
|
||||||
/* "files": true, */
|
/* "files": true, */
|
||||||
"files": ["templates/*.tmpl", "assets/*.css"],
|
"files": ["templates/*.tmpl", "assets/input/css/*.css"],
|
||||||
"watchEvents": [
|
"watchEvents": [
|
||||||
"change"
|
"change"
|
||||||
],
|
],
|
||||||
|
2
embed.go
2
embed.go
@ -6,6 +6,6 @@ var (
|
|||||||
//go:embed all:templates
|
//go:embed all:templates
|
||||||
templates embed.FS
|
templates embed.FS
|
||||||
|
|
||||||
//go:embed assets assets/img
|
//go:embed all:assets/public
|
||||||
assets embed.FS
|
assets embed.FS
|
||||||
)
|
)
|
||||||
|
2
gen.go
2
gen.go
@ -1,4 +1,4 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
//go:generate npm i
|
//go:generate npm i
|
||||||
//go:generate npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --minify
|
//go:generate npx tailwindcss -i ./assets/input/css/tailwind.css -o ./assets/public/css/pcmt.css --minify
|
||||||
|
4
justfile
4
justfile
@ -1,7 +1,7 @@
|
|||||||
# run tailwindcss tool in watch mode.
|
# run tailwindcss tool in watch mode.
|
||||||
watch-tw:
|
watch-tw:
|
||||||
npm i
|
npm i
|
||||||
npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --watch
|
npx tailwindcss -i ./assets/input/css/tailwind.css -o ./assets/public/css/pcmt.css --watch
|
||||||
|
|
||||||
# start browser-sync.
|
# start browser-sync.
|
||||||
watch-brs:
|
watch-brs:
|
||||||
@ -11,7 +11,7 @@ watch-brs:
|
|||||||
# build app stylesheets using the tailwindcss cli tool.
|
# build app stylesheets using the tailwindcss cli tool.
|
||||||
tw:
|
tw:
|
||||||
npm i
|
npm i
|
||||||
npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --minify
|
npx tailwindcss -i ./assets/input/css/tailwind.css -o ./assets/public/css/pcmt.css --minify
|
||||||
|
|
||||||
# build the application.
|
# build the application.
|
||||||
build:
|
build:
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
"tailwindcss": "^3.3.0"
|
"tailwindcss": "^3.3.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch-tw": "npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --watch",
|
"watch-tw": "npx tailwindcss -i ./assets/input/css/tailwind.css -o ./assets/public/css/pcmt.css --watch",
|
||||||
"watch-brs": "npx browser-sync start --config bs.js",
|
"watch-brs": "npx browser-sync start --config bs.js",
|
||||||
"tw": "npx tailwindcss -i ./assets/input.css -o ./assets/pcmt.css --minify"
|
"tw": "npx tailwindcss -i ./assets/input/css/tailwind.css -o ./assets/public/css/pcmt.css --minify"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
|
|
||||||
<link rel="icon" href="/assets/img/logo-pcmt.svg" type="image/svg+xml">
|
<link rel="icon" href="/assets/img/logo-pcmt.svg" type="image/svg+xml">
|
||||||
<link href="/assets/pcmt.css" rel="preload" as="style">
|
<link href="/assets/css/pcmt.css" rel="preload" as="style">
|
||||||
<link href="/assets/pcmt.css" rel="stylesheet">
|
<link href="/assets/css/pcmt.css" rel="stylesheet">
|
||||||
|
|
||||||
{{- if .DevelMode -}}
|
{{- if .DevelMode -}}
|
||||||
<!-- <link href="http://localhost:3002/browser-sync/browser-sync-client.js?v=2.29.1" rel="preload" as="script"> -->
|
<!-- <link href="http://localhost:3002/browser-sync/browser-sync-client.js?v=2.29.1" rel="preload" as="script"> -->
|
||||||
|
Loading…
Reference in New Issue
Block a user