@@ -4,11 +4,7 @@ package assets
44
55import (
66 "embed"
7- "fmt"
8- "os"
9- "path/filepath"
10- "runtime"
11- "sort"
7+ "slices"
128 "strings"
139)
1410
@@ -44,31 +40,31 @@ var (
4440 VCLESISynth string
4541)
4642
43+ //go:embed all:css
44+ var cssFiles embed.FS
45+
4746var CombinedCSS []byte
4847
4948func init () {
50- // Get the directory of the current source file to ensure css files are found
51- _ , currentFile , _ , ok := runtime .Caller (0 )
52- if ! ok {
53- panic ("failed to get current file path" )
54- }
55- currentDir := filepath .Dir (currentFile )
56- cssDir := filepath .Join (currentDir , "css" )
57-
58- // Generate the combined css file
59- matches , err := filepath .Glob (filepath .Join (cssDir , "*.css" ))
49+ files , err := cssFiles .ReadDir ("css" )
6050 if err != nil {
6151 panic (err )
6252 }
63- sort .Strings (matches )
53+ names := make ([]string , len (files ))
54+ for i , f := range files {
55+ names [i ] = f .Name ()
56+ }
57+ slices .Sort (names )
6458
65- var parts []string
66- for _ , path := range matches {
67- data , err := os .ReadFile (path )
59+ // Read and join all files
60+ var sb strings.Builder
61+ for _ , name := range names {
62+ data , err := cssFiles .ReadFile ("css/" + name )
6863 if err != nil {
69- panic (fmt . Sprintf ( "failed to read %s: %v" , path , err ) )
64+ panic (err )
7065 }
71- parts = append (parts , string (data ))
66+ sb .Write (data )
67+ sb .WriteByte ('\n' )
7268 }
73- CombinedCSS = []byte (strings . Join ( parts , " \n " ))
69+ CombinedCSS = []byte (sb . String ( ))
7470}
0 commit comments