JavaScript Minifier (e.g. YUI) Integrated To ASP.NET Webdeploy Publish
I have a javascript file that I minify using the Yahoo YUI. When I 'Publish' the web application project, I want it to only copy the .min.js file and not the original one too. I ca
Solution 1:
You can use MSBuild Community Task project and the Exec task to do this. Here is an example.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<yuiCompressor>java -jar Libraries\yuicompressor-2.3.6.jar</yuiCompressor>
</PropertyGroup>
<PropertyGroup>
<Major>1</Major>
<Minor>0</Minor>
<Build>0</Build>
<Revision>1</Revision>
<BindMinor>0</BindMinor>
<BindBuild>0</BindBuild>
<BindRevision>0</BindRevision>
</PropertyGroup>
<ItemGroup>
<CssFiles Include="css\site.css" />
<CssFiles Include="css\gray.css" />
<JsFiles Include="scripts\base.js" />
<JsFiles Include="scripts\lib.js" />
<JsFiles Include="scripts\project.js" />
</ItemGroup>
<Target Name="Minimize" DependsOnTargets="Version">
<!-- CSS Merge and Minimize -->
<Merge Mode="TextLine"
SourceFiles="@(CssFiles)"
DestinationFile="merged.css" />
<Exec Command="$(yuiCompressor) --type css merged.css -o css\project-$(Revision).css" />
<!-- js Merge and Minimize -->
<Merge Mode="TextLine"
SourceFiles="@(JsFiles)"
DestinationFile="merged.js" />
<Exec Command="$(yuiCompressor) --type js merged.js -o scripts\project-$(Revision).js" />
<Delete Files="merged.css" />
<Delete Files="merged.js" />
</Target>
</Project>
Solution 2:
If it's a web application (and not a web site), just change the Build Action to None in the properties window. This will prevent the original file from being copied when the app is published.
Post a Comment for "JavaScript Minifier (e.g. YUI) Integrated To ASP.NET Webdeploy Publish"