Excluding individual files

Feb 17, 2011 at 7:56 PM

I'm using the ItemGroups to compress and combine certain javascript files.  For example I have about 10 files that deal with the jquery library and I want to combine them into a single compress file.  In order to do that, jquery.js needs to be compressed and combined first so that when the page references the single javascript file, it has the correct context for the custom jquery library I'm creating.  Is there a way to do something like this,

Include="jquery.js" first

then Include all other javascript files like jquery.*.js except for the file jquery.js?

Thanks in advance!

 

 

Coordinator
Feb 18, 2011 at 12:28 AM
Edited Feb 18, 2011 at 12:31 AM

Hi Joshgk00,

thanks for dropping by and giving this library a go.

Assumption to my Answer:
Quote: I'm using the ItemGroups
 
Assumption: you're using an xml file to define all the files, how to compresses, where to, etc etc...

Answer:
sure is! the ORDER of the files (listed in the xml file***) is crucial. They are handled on a first come, first server basis. So if you need to make sure that the jquery.js file is combined first, then it needs to be listed first

EG. (here's a sample Xml file taken from the most recent source code, at the time of this post).

 

<ItemGroup>
    <JavaScriptFiles Include="jquery-1.3.2.js"/>
    <JavaScriptFiles Include="nextFile.js"/>
    <JavaScriptFiles Include="anotherFile.js"/>
</ItemGroup>

 

but that could be too tedius for you if u have a lot of files .. and especially if u're adding and removing files as they appear. So maybe we can leverage wildcards but remove the important ones....

 

<ItemGroup>
    <JavaScriptFiles Include="jquery-1.3.2.js"/> <!-- Need this one first, so it get fired first -->
    <JavaScriptFiles Include="*.js" Exclude="jquery-1.3.2.js"/> <!-- All the other js files EXCEPT the first one .. otherwise it would be double copied -->
</ItemGroup>

 

I've not tried this, but it looks like it should work.

Give it a go and report back, if u don't mind :)


*** Note: the example xml file that comes with the code says:

<!-- All the files. They will be handled (I assume) in alphabetically. -->

I think this is wrong. I think it's first in, best dressed. I think .....