I m using ajaxmin to minify all my JS files. Everything works perfectly but i have little problem with the way the output files are generated.
Currently what happenes is the JS files are minified next to its path. e.g If the original path is includes/js/test.js then it is minified at includes/js/test.min.js.
I want my all js files to minify at different location then the original location. e.g. My all js files are under includes/js/JSFILESHERE and i wanted these js files to be minified at includes/minifiedjs/MINIFIEDJSFILESHERE.
i m using the below code.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\AjaxMin.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
<JS Include="\js\*.js" Exclude="**\*.min.js;" />
</ItemGroup>
<AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\js\.js$" JsTargetExtension=".min.js"/>
</Target>
Please help.
Apologies for replying bit late to this question.
Here is the solution I used for my project -
<Target Name="AfterBuild">
<PropertyGroup>
<DestinationPath>$(MSBuildProjectDirectory)\build-publish</DestinationPath>
</PropertyGroup>
<ItemGroup>
<JS Include="Scripts\app\**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
</ItemGroup>
<Copy SourceFiles="@(JS)" DestinationFiles="@(JS -> '$(DestinationPath)\%(RecursiveDir)%(Filename).src%(Extension)')" Condition="'%(Extension)'=='.js'">
<Output ItemName="JavaScriptFiles" TaskParameter="DestinationFiles" />
</Copy>
<AjaxMin JsSourceFiles="@(JavaScriptFiles)" JsSourceExtensionPattern="\.src.js$" JsTargetExtension="min.js" SourceMapType="V3">
</AjaxMin>
Here am first copying the files to a destination folder(recursively) and then applying the Minification on them. I needed source map files so thats why I kept my original files but if you dont need source maps then you could delete source files after minification is complete.