My ideal situation is to automatically minify CSS files and add them to the git commit. I’m not sure if #4 below can be done, but I would like the following flow to be performed:
- Modify CSS file
- Add to staging area
- Commit
- Run script that updates the minified files and adds them to the commit
- Commit completes
If there is another way, I’d be interested in that as well.
Whether you should is another matter, but you can.
in .git/hooks/, write a script in your language of choice (make sure it’s executable) named pre-commit
in that script, run your minifier command, and do ‘git add ‘
here’s an example of someone who minifies javascript this way:
https://gist.github.com/786460
a test hook I wrote:
after running the commit, test1_diff.css was in the working directory, and in git, tracked.