Rather than committing built assets to the repo, consider using a prepare script, which builds the distributable package post-install (e.g., see How to Distribute a Pattern Library as an npm Package from a Private Git Repo).
This strategy would allow us to git-ignore both the dist and compiled-grammar directories.