From c402ee9b2363ea18b11464b219be9643e37d2a67 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 22 Jun 2025 21:18:01 +0200 Subject: [PATCH] fix(dev): ensure frontend assets before compile in magefile (#992) --- magefile.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/magefile.go b/magefile.go index 4accd3f7f..86d8ed9b3 100644 --- a/magefile.go +++ b/magefile.go @@ -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) }