Permalink
Browse files

Merge pull request #18 from alvincrespo/requirejs

RequireJS Support
  • Loading branch information...
2 parents 2bcfcbd + 1a70fb7 commit a4a47076505942fed5d67e44dfaf277285df5e9f @roblarsen roblarsen committed Feb 10, 2012
Showing with 22 additions and 2 deletions.
  1. +17 −2 build.xml
  2. +5 −0 config/project.properties
View
@@ -644,9 +644,24 @@
-->
<echo message="Update the HTML to reference our concatenated script file: ${scripts.js}"/>
+ <!-- Determines which Regex for AMD use -->
+ <var name="matchRegex" value=""/>
+ <var name="replaceRegex" value=""/>
+ <if>
+ <isset property="script.require.path"/>
+ <then>
+ <echo message="Updating HTML to reflect the use of RequireJS"/>
+ <var name="matchRegex" value="&lt;!-- scripts concatenated [\d\w\s\W]*&lt;script.*data-main=['&quot;]?(.*)/${file.root.script}(?:\?.*)?['&quot;] src=['&quot;]?(.*)${script.require.path}(?:\?.*)?['&quot;]?\s*&gt;\s*&lt;/script&gt;[\d\w\s\W]*&lt;!-- end ((scripts)|(concatenated and minified scripts))\s*--&gt;"/>
+ <var name="replaceRegex" value="&lt;script data-main='\1/${scripts.sha}.js\' src='${script.require.path}'&gt;&lt;/script&gt;"/>
+ </then>
+ <else>
+ <echo message="Updating HTML to reflect the use of default script inclusion"/>
+ <var name="matchRegex" value="&lt;!-- scripts concatenated [\d\w\s\W]*&lt;script.*src=['&quot;]?(.*)/${file.root.script}(?:\?.*)?['&quot;]?\s*&gt;\s*&lt;/script&gt;[\d\w\s\W]*&lt;!-- end ((scripts)|(concatenated and minified scripts))\s*--&gt;" />
+ <var name="replaceRegex" value="&lt;script src='\1/${scripts.sha}.js\'&gt;&lt;/script&gt;" />
+ </else>
+ </if>
<!-- style.css replacement handled as a replacetoken above -->
- <replaceregexp match="&lt;!-- scripts concatenated [\d\w\s\W]*&lt;script.*src=['&quot;]?(.*)/${file.root.script}(?:\?.*)?['&quot;]?\s*&gt;\s*&lt;/script&gt;[\d\w\s\W]*&lt;!-- end ((scripts)|(concatenated and minified scripts))\s*--&gt;"
- replace="&lt;script src='\1/${scripts.sha}.js\'&gt;&lt;/script&gt;" flags="m">
+ <replaceregexp match="${matchRegex}" replace="${replaceRegex}" flags="m">
<fileset dir="${dir.intermediate}" includes="${page-files}"/>
</replaceregexp>
<!--[! use comments like this one to avoid having them get minified -->
@@ -101,3 +101,8 @@ tool.htmlcompressor.opts.extra =
# valid values are between 1 and 40.
# shorter values use less bytes at the expense of increasing the probability of a hash collision.
#hash.length = 7
+
+# Optional property used to determine whether to include requirejs' implementation of <script> in the build process
+# Uncomment and include the path
+# Example: script.require.path = js/libs/require-jquery.js
+# script.require.path =

0 comments on commit a4a4707

Please sign in to comment.