Skip to content
This repository
Browse code

Merge pull request #56 from rolos79/master

Adding LESS CSS to build script
  • Loading branch information...
commit b4615f5982407d716bbba7b4d0cb1b61177578c1 2 parents ff45c0b + 844bcf7
Rob Larsen authored April 29, 2012
41  build.xml
@@ -661,6 +661,21 @@
661 661
         replace="<link\1href='\2/${css.sha}.css'\3" flags="m">
662 662
           <fileset dir="${dir.intermediate}" includes="${page-files}"/>
663 663
       </replaceregexp>
  664
+      
  665
+      <!-- Tidy up HTML when compiling LESS -->
  666
+      <if>
  667
+            <equals arg1="${build.css.less}" arg2="true"/>
  668
+            <then>
  669
+                <echo message="Removing LESS CSS Script from HTML..."/>
  670
+                <replaceregexp match="&lt;!-- less script [\d\w\s\W]* end less script --&gt;" replace="">
  671
+			        <fileset dir="${dir.intermediate}" includes="${page-files}"/>
  672
+			    </replaceregexp>
  673
+			    <echo message="Changing rel attribute to 'stylesheet' from 'stylesheet/less'"/>
  674
+			    <replaceregexp match="rel=['&quot;]stylesheet/less['&quot;]" replace="rel='stylesheet'">
  675
+			        <fileset dir="${dir.intermediate}" includes="${page-files}"/>
  676
+			    </replaceregexp>
  677
+            </then>
  678
+        </if>
664 679
 
665 680
       <foreach list="${file.stylesheets}" param="css_file" target="-css-remove-concatenated-stylesheets" />
666 681
 
@@ -922,6 +937,19 @@
922 937
                 </if>
923 938
             </sequential>
924 939
         </for>
  940
+        
  941
+        <if>
  942
+            <equals arg1="${build.css.less}" arg2="true"/>
  943
+            <then>
  944
+                <echo message="Processing LESS CSS..."/>
  945
+                <lessjs input="${dir.intermediate}/${dir.css}/style-concat.css" output="${dir.intermediate}/${dir.css}/style-concat.css" />
  946
+            </then>
  947
+            <else>
  948
+                <echo message="NOT Processing LESS CSS"/>
  949
+            </else>
  950
+        </if>
  951
+        
  952
+        
925 953
         <echo message="Minifying css..."/>
926 954
 
927 955
         <apply executable="java" parallel="false">
@@ -1089,7 +1117,18 @@
1089 1117
         </apply>
1090 1118
     </target>
1091 1119
 
1092  
-
  1120
+	<macrodef name="lessjs">
  1121
+	    <attribute name="input" />
  1122
+	    <attribute name="output" />
  1123
+	    <sequential>
  1124
+	        <java jar="./${dir.build.tools}/${tool.rhino}" fork="true" output="@{output}">
  1125
+	            <arg path="./${dir.build.tools}/${tool.lesscss}" />
  1126
+	            <arg path="@{input}" />
  1127
+	        </java>
  1128
+	        <echo>Lessjs: generated @{output}</echo>
  1129
+	    </sequential>
  1130
+	</macrodef>
  1131
+	
1093 1132
 	<!-- Import project.xml (put any custom build targets in this file so that they aren't overwritten when build.xml is updated) -->
1094 1133
 	<!-- See: https://github.com/h5bp/html5-boilerplate/issues/704 for discussion of the original pull request-->
1095 1134
 	<import file="./project.xml" />
7  config/default.properties
@@ -28,7 +28,6 @@ slug.modules		= modules
28 28
 dir.css             = css
29 29
 dir.images          = img
30 30
 
31  
-
32 31
 #
33 32
 # HTML, PHP, etc files to clean and update script/css references
34 33
 #
@@ -79,6 +78,11 @@ file.root.script    = main.js
79 78
 file.root.stylesheet    = style.css
80 79
 
81 80
 #
  81
+# Defaults to not processing LESS CSS (http://lesscss.org)
  82
+#
  83
+build.css.less		= false
  84
+
  85
+#
82 86
 # Default Stylesheet
83 87
 #
84 88
 file.default.stylesheets    =
@@ -119,6 +123,7 @@ tool.rhino                  = rhino.jar
119 123
 tool.jslint                 = fulljslint.js
120 124
 tool.jshint                 = fulljshint.js
121 125
 tool.csslint                = csslint-rhino.js
  126
+tool.lesscss				= less-rhino-1.3.0.js
122 127
 
123 128
 # Default Lint Utils Options
124 129
 tool.jshint.opts            = maxerr=25,eqeqeq=true
11  config/project.properties
@@ -17,6 +17,17 @@
17 17
 #
18 18
 file.stylesheets  =
19 19
 
  20
+# 
  21
+# LESS CSS Processing (http://lesscss.org)
  22
+#
  23
+# You must tell the script if you want to process your CSS as LESS
  24
+# build.css.less			= true
  25
+#
  26
+# You must also set your LESS css file as the root CSS file
  27
+# 
  28
+# Example:
  29
+# file.root.stylesheet    = style.less
  30
+# 
20 31
 
21 32
 # Web Pages
22 33
 #
1  readme.md
Source Rendered
@@ -21,6 +21,7 @@ Faster page load times and happy end users :)
21 21
 * Updates your HTML to use the minified jQuery instead of the development version
22 22
 * Remove unneeded references from HTML (like a root folder favicon)
23 23
 * Runs your JavaScript through a code quality tool (optional)
  24
+* Optionally precompile LESS formatted CSS 
24 25
 
25 26
 <img src="http://html5boilerplate.com/img/chart.png">
26 27
 
3,150  tools/less-rhino-1.3.0.js
3150 additions, 0 deletions not shown

0 notes on commit b4615f5

Please sign in to comment.
Something went wrong with that request. Please try again.