Search code examples
htmlgitdeploymentlessgit-post-receive

replace styles.less with styles.css via git post-receive


I have a local development web with an index.html which is using:

<!-- 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>

When I am ready editing I commit/push to my development server and the git post-receive hook runs my build.sh and builds my css / requireJS / smartsprites app.

How can I replace the above code in my static HTML file with:

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

without switching to server-side scripting (PHP/etc) or on the fly node.js css rendering.

In my build.sh script? With regexp? How? An example would be nice.


Solution

  • You can just use sed:

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

    I haven't used git-post-receive (I didn't even know it existed! thanks :P), but you could just shove it into your build.sh file or whatever file runs when you push your files to the server.