Html 通过git post receive将styles.less替换为styles.css

Html 通过git post receive将styles.less替换为styles.css,html,git,deployment,less,git-post-receive,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 receiv

我有一个本地开发网站,其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钩子运行我的build.sh并构建我的css/requireJS/smartsprites应用程序

如何将静态HTML文件中的上述代码替换为:

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

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


在我的build.sh脚本中?用regexp?怎么用?举个例子就好了。

您可以使用
sed

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

我没有使用过git post receive(我甚至不知道它的存在!谢谢:p),但是你可以将它放入你的
build.sh
文件中,或者在你将文件推送到服务器时运行的任何文件中。

谢谢git hook。每次推送代码时,我都会手动更改内容,因此这应该会使管理更容易。