Targeting Multiple HTML Files in the HTML5 Boilerplate Build Script

This came up in a comment here, so I thought I’d bubble this little tip to the top.

To target multiple files for URL rewriting in the HTML5 Boilerplate build script (as of version 0.95) use the fileset element instead of the file argument in the “html” target:

  
<target name="html" depends="">

    <echo message="Clean up the html..."/>

    <!-- style.css replacement handled as a replacetoken above -->

    <replaceregexp match="&lt;!-- scripts concatenated [\d\w\s\W]*?!-- end concatenated and minified scripts--&gt;" 
    	replace="&lt;script src='${dir.js}/scripts-${build.number}.min.js\'&gt;&lt;/script&gt;" flags="m">
	  
        <!-- grab everything html -->

       <fileset dir="./${dir.publish}/" includes="**/*.html"/>

    </replaceregexp>

    <replaceregexp match="&lt;!-- yui profiler[\d\w\s\W]*?end profiling code --&gt;" replace=" " flags="m">

        <!-- grab everything html -->

        <fileset dir="./${dir.publish}/" includes="**/*.html"/>

    </replaceregexp>

    <!--[! use comments like this one to avoid having them get minified -->

</target>

You then need to expand the fileset element in the next three targets (htmlbuildkit, htmlclean, htmlcompress) to include subfolders.

Replace

<fileset dir="./${dir.publish}/" includes="*.html"/>

with

<fileset dir="./${dir.publish}/" includes="**/*.html"/>

And that should do it.

Leave a Reply

Your email address will not be published. Required fields are marked *