.NET YUI 压缩机:如何包含同一目录中除一个之外的所有 css/js 文件?
我将 YUI Compressor 连接到我的 MVC 3 项目。我有一个包含 css 文件的文件夹,另一个包含 js 文件的文件夹。构建时,我想包含 css 目录中的所有文件,除了一个。 js也同样如此。我怎样才能做到这一点?
这是 XML:
<Target Name="AfterBuild">
<CallTarget Targets="Compress" Condition=" '$(Configuration)' == 'Release' " />
</Target>
<Target Name="Compress">
<ItemGroup>
<!-- Single files, listed in order of dependency. Use * for wildcards -->
<CssFiles Include="$(ProjectDir)\Content\*.css" Exclude="$(ProjectDir)Content\All.css" />
<JavaScriptFiles Include="$(ProjectDir)\Scripts\*.js" Exclude="$(ProjectDir)Scripts\All.js" />
</ItemGroup>
<MakeDir Directories="$(ProjectDir)..\JsCssRelease" />
<CompressorTask
CssFiles="@(CssFiles)"
DeleteCssFiles="false"
CssOutputFile="$(ProjectDir)..\JsCssRelease\All.css"
CssCompressionType="YuiStockCompression"
JavaScriptFiles="@(JavaScriptFiles)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="True"
DisableOptimizations="False"
EncodingType="Default"
DeleteJavaScriptFiles="false"
LineBreakPosition="-1"
JavaScriptOutputFile="$(ProjectDir)..\JsCssRelease\All.js"
LoggingType="ALittleBit"
ThreadCulture="en-us"
IsEvalIgnored="false" />
</Target>
我似乎找不到更多信息 http://yuicompressor.codeplex.com/。
目前发生的情况是,它包含所有文件,但不排除指定的文件。
I hooked up YUI Compressor to my MVC 3 project. I got one folder with css files and another one with js files. When building, I want to include all of the files from css directory, except for one. Same goes for js. How can I accomplish that?
Here is the XML:
<Target Name="AfterBuild">
<CallTarget Targets="Compress" Condition=" '$(Configuration)' == 'Release' " />
</Target>
<Target Name="Compress">
<ItemGroup>
<!-- Single files, listed in order of dependency. Use * for wildcards -->
<CssFiles Include="$(ProjectDir)\Content\*.css" Exclude="$(ProjectDir)Content\All.css" />
<JavaScriptFiles Include="$(ProjectDir)\Scripts\*.js" Exclude="$(ProjectDir)Scripts\All.js" />
</ItemGroup>
<MakeDir Directories="$(ProjectDir)..\JsCssRelease" />
<CompressorTask
CssFiles="@(CssFiles)"
DeleteCssFiles="false"
CssOutputFile="$(ProjectDir)..\JsCssRelease\All.css"
CssCompressionType="YuiStockCompression"
JavaScriptFiles="@(JavaScriptFiles)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="True"
DisableOptimizations="False"
EncodingType="Default"
DeleteJavaScriptFiles="false"
LineBreakPosition="-1"
JavaScriptOutputFile="$(ProjectDir)..\JsCssRelease\All.js"
LoggingType="ALittleBit"
ThreadCulture="en-us"
IsEvalIgnored="false" />
</Target>
I can't seem to find any more info then there is at
http://yuicompressor.codeplex.com/.
What currently happens is that it includes all files and doesn't exclude the ones specified.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
德鲁什金的评论是正确的。在
Include
属性中的$(ProjectDir)
后面有一个额外的斜杠,但在Exclude
属性中没有,这会导致不同的文件名,即使\\
而不是\
仍然可以访问文件。driushkin's comment was on the right way. You have an extra slash after
$(ProjectDir)
in theInclude
attribute but not on theExclude
one, leading to different file names, even if\\
instead of\
still works to access the files.