<?xml version="1.0"?>
<!--
This tagneticconfig file will "optimize" the JS libraries by removing
code sections that have their "use" variable set as false (see _OptionsOverlay.js),
remove JS comments, multiple whitespace characters, and any lines breaks. It
will also create an OptLib.js with all of the JS files collected into a single
file.
-->
<tagneticconfig>
  <compilation>
    <source>.</source>
    <destination>optimized</destination>
    <!-- Only match js files in the currenct directory -->
    <filefilter type="regexp">[^\/\\].*\.js$</filefilter>
    <recursedirectories>false</recursedirectories>
    <copynonmatchingfiles>false</copynonmatchingfiles>
    <postfilters>
      <!-- Strip JS line comments. Strip these BEFORE stripping block comments.
            LIMITATIONS:
              - It isn't smart enough to know if you are in a javascript string, so it will match
               things like document.write('////this comment will match'). This situation should
               be mitigated by the match that tries not to match things like
               [document.location = 'http://www.www.com';], but it isn't perfect. -->
      <postfilter classname="org.tagnetic.core.filecontentfilter.RegExpFileContentFilter">
        <param name="pattern">(?m)[^:*]//.*$</param>      
        <param name="replacement"></param>
      </postfilter>
      <!-- Strip JS block comments The (?sm) turns on
            the MULTILINE and DOTALL flags.
            LIMITATIONS:
              - Always put start and end comments on a separate line, or separate them
                by a space: /*blah blah*/ /* blah blah */ DO NOT DO: /*blah blah*//* blah blah */ 
              - It isn't smart enough to know if you are in a javascript string, so it will match
                things like document.write('blah /* this comment will match */'). -->
      <postfilter classname="org.tagnetic.core.filecontentfilter.RegExpFileContentFilter">
        <param name="pattern">(?sm)/\*.*?\*/</param>      
        <param name="replacement"></param>
      </postfilter>
      <!-- Strip multiple whitespace down to one white space. -->
      <postfilter classname="org.tagnetic.core.filecontentfilter.RegExpFileContentFilter">
        <param name="pattern">[ \t\x0B\f]+</param>      
        <param name="replacement"> </param>
      </postfilter>
      <!-- Remove line breaks -->
      <postfilter classname="org.tagnetic.core.filecontentfilter.RegExpFileContentFilter">
        <param name="pattern">(\r\n)+|(\n)+|(\r)+</param>      
        <param name="replacement"></param>      
      </postfilter>
    </postfilters>
    <fileoverlays>
      <!-- Add an overlay that defines the flags for which JS content is desired -->
      <fileoverlay position="before">
        <file>\.js$</file>
        <overlay>_OptionsOverlay.js</overlay>
      </fileoverlay>
    </fileoverlays>
  </compilation>
</tagneticconfig>

