Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 views
in Technique[技术] by (71.8m points)

individually minify JS and CSS in Visual Studio 2010

I'm currently migrating a project to Visual Studio 2010 and am trying to figure out how to minify JS and CSS files individually on build.

In Visual Studio 2008 I used a Web Deployment Projects with a build task that referenced the C# port of the YUI Compressor. In Visual Studio 2010 Web Deployment Projects seem to have been integrated into the build process. Now there is this Microsoft AJAX Minifier in public beta and I'm more confused than ever.

I found this blog post which makes the business with the Microsoft AJAX Minifier a non-starter because of CSS limitations. This shouldn't be confusing...it should be a check box in Visual Studio 2010.

Is there a simple way do this with Visual Studio 2010? What am I missing here people?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This should still be possible with VS2010 by editing the csproj aka msbuild file.

Taken from this thread on CodePlex.

<ItemGroup>
  <JavaScriptFiles Remove="@(JavaScriptFiles)" />
  <JavaScriptFiles Include="../js/2.js"/>
</ItemGroup>
<CompressorTask
  JavaScriptFiles="@(JavaScriptFiles)"
  ObfuscateJavaScript="True"
  PreserveAllSemicolons="False"
  DisableOptimizations="Nope"
  EncodingType="Default"
  DeleteJavaScriptFiles="false"
  LineBreakPosition="-1"
  JavaScriptOutputFile="../js/2.min.js"
  LoggingType="ALittleBit"
  ThreadCulture="en-au"
  IsEvalIgnored="false"/> 
<ItemGroup>
  <JavaScriptFiles Remove="@(JavaScriptFiles)" />
  <JavaScriptFiles Include="../js/3.js" />
  <JavaScriptFiles Include="../js/4.js" />
</ItemGroup>
<CompressorTask
  CssFiles="@(CssFiles)"
  DeleteCssFiles="false"
  CssOutputFile="../css/release.css"
  CssCompressionType="YuiStockCompression"
  JavaScriptFiles="@(JavaScriptFiles)"
  ObfuscateJavaScript="True"
  PreserveAllSemicolons="False"
  DisableOptimizations="Nope"
  EncodingType="Default"
  DeleteJavaScriptFiles="false"
  LineBreakPosition="-1"
  JavaScriptOutputFile="../js/3.min.js"
  LoggingType="ALittleBit"
  ThreadCulture="en-au"
  IsEvalIgnored="false"/>


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...