fix(dev): ensure frontend assets before compile in magefile (#992)

This commit is contained in:
kolaente 2025-06-22 21:18:01 +02:00 committed by GitHub
parent 2a5ee13c22
commit c402ee9b23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 0 deletions

View File

@ -645,6 +645,26 @@ func (Build) Clean() error {
// Builds a vikunja binary, ready to run
func (Build) Build() {
mg.Deps(initVars)
// Check if the frontend dist folder exists
distPath := filepath.Join(RootPath, "frontend", "dist")
if _, err := os.Stat(distPath); os.IsNotExist(err) {
if err := os.MkdirAll(distPath, 0o755); err != nil {
fmt.Printf("Error creating %s: %s\n", distPath, err)
os.Exit(1)
}
}
indexFile := filepath.Join(distPath, "index.html")
if _, err := os.Stat(indexFile); os.IsNotExist(err) {
f, err := os.Create(indexFile)
if err != nil {
fmt.Printf("Error creating %s: %s\n", indexFile, err)
os.Exit(1)
}
f.Close()
fmt.Printf("Warning: %s not found, created empty file\n", indexFile)
}
runAndStreamOutput("go", "build", Goflags[0], "-tags", Tags, "-ldflags", "-s -w "+Ldflags, "-o", Executable)
}