Bundling NuxtJS dist directory using go:embed

Viewed 54

I have a web app using a NuxtJS frontend being served from a Golang web micro-service.

I am using go:embed dist to ship the frontend assets into the web binary and running it all in a Docker container. For non-Gophers, go:embed is a directive that bundles files or directories into the Go binary. It's a compile error to use go:embed on a directory that doesn't exist.

Usually, you don't commit the dist directory to VCS, but if I don't, then all my CI builds fail because I cannot compile the web service since dist doesn't exist.

I tried adding a .gitignore inside the dist folder like this:

*
!.gitigore

I was hoping this would commit the empty dist folder to VCS, but still not commit any of the assets. This worked fine, until I ran the NuxtJS build and it deleted the .gitignore. I assume it deletes the whole directory and recreates it.

Does anybody know whether there is a configuration option to keep the dist folder around between builds, or at least to not delete the .gitignore within it?

0 Answers
Related