通过git post-receive替换styles.css中的styles.less

时间:2011-09-28 15:53:32

标签: html git deployment less git-post-receive

我有一个带有index.html的本地开发网站,该网站正在使用:

<!-- LESS -->
<link rel="stylesheet/less" type="text/css" href="css/styles.less" />
<script src="js/lib/less-1.1.3.min.js" type="text/javascript"></script>

当我准备编辑时,我提交/推送到我的开发服务器,git post-receive hook运行我的build.sh并构建我的css / requireJS / smartsprites应用程序。

如何使用以下命令替换静态HTML文件中的上述代码:

<link rel="stylesheet" type="text/css" href="css/styles.css" />

无需切换到服务器端脚本(PHP / etc)或动态node.js css渲染。

在我的build.sh脚本中?有正则表达式?怎么样?一个例子就是很好。

1 个答案:

答案 0 :(得分:2)

您可以使用sed

sed -i -e 's/styles\.less/styles\.css/g' index.html

我没有使用git-post-receive(我甚至不知道它存在!谢谢:P),但你可以把它推到你的build.sh文件或任何文件运行时推动你的文件到服务器。