通过git钩子来缩小CSS文件 [英] Minify CSS files via git hook

查看:104
本文介绍了通过git钩子来缩小CSS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理想情况是自动缩小CSS文件并将它们添加到git commit中。我不确定下面的#4是否可以完成,但我想要执行以下流程:


  1. 修改CSS文件

  2. 添加到暂存区

  3. 提交

  4. 运行更新缩小文件并添加它们的脚本到提交

  5. 提交完成

如果还有其他方法, '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:

  1. Modify CSS file
  2. Add to staging area
  3. Commit
  4. Run script that updates the minified files and adds them to the commit
  5. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆