通过git钩子来缩小CSS文件 [英] Minify CSS files via git hook
问题描述
我的理想情况是自动缩小CSS文件并将它们添加到git commit中。我不确定下面的#4是否可以完成,但我想要执行以下流程:
- 修改CSS文件
- 添加到暂存区
- 提交
- 运行更新缩小文件并添加它们的脚本到提交
- 提交完成
如果还有其他方法, 'd也对此感兴趣。
您是否应该是另一回事,但您可以。
b$ b
in .git / hooks /,用你选择的语言编写一个脚本(确保它是可执行的),在脚本中命名为pre-commit
,运行你的minifier命令, 'git add'
以下是一个以这种方式缩小JavaScript的人的示例:
https://gist.github.com/786460
我写了一个测试钩子:
#/ bin / sh
traeiouAEIOU< test1.css> test1_diff.css
git add test1_diff.css
运行提交后,test1_diff.css为在工作目录和git中进行跟踪。
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:
#/bin/sh
tr "aeiou" "AEIOU" < test1.css > test1_diff.css
git add test1_diff.css
after running the commit, test1_diff.css was in the working directory, and in git, tracked.
这篇关于通过git钩子来缩小CSS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!