从发布版本中排除未缩小的 java 脚本

发布于 2024-10-05 01:48:04 字数 973 浏览 0 评论 0原文

我有一个 .NET 库,它提供了一些 AJAX 控件。该库是使用 Visual Studio 2008 构建的。ajax minifier 任务用于自动生成缩小的 javascript 文件。 在调试版本中,我需要原始 javascript 文件来调试 javascript,但在发布版本中,这些文件没有用处。

你会推荐什么?在发布中忽略它们并让它们炸毁文件大小?加载时间会受到惩罚吗?或者您会将它们从发布版本中删除吗?如何?我可以修改项目文件并添加条件属性。但这并不能很好地集成到 Visual Studio 中。

编辑:

澄清:主要问题是:包含和排除非缩小文件的参数是什么。

更新:

刚刚找到了一个解决方案,一个很好的自动排除解决方案。她是我的项目文件的一部分:

<ItemGroup>
  <EmbeddedJavascript Include="MyJavascript.debug.js" />
  <EmbeddedResource Include="MyJavascript.js" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="BeforeBuild">
  <ItemGroup Condition=" '$(Configuration)' != 'Release' ">
    <EmbeddedResource Include="@(EmbeddedJavascript)" />
  </ItemGroup>
  <AjaxMin JsSourceFiles="@(EmbeddedJavascript)" JsSourceExtensionPattern="\.debug\.js$" JsTargetExtension=".js" />
</Target>

I have a .NET library which provides some AJAX controls. The library is build with Visual Studio 2008. The ajax minifier task is used to auto generate minified javascript files.
In a debug build I need the original javascript files for debugging the javascript, but in a release build these have no usage.

What would you recommend? Ignore them in the release and let them blow up the file size? Would there be a penality in loading time? Or would you remove them from the release build? How? I could modify the project file and add a condition attribute. But this does not well integrate in Visual Studio.

EDIT:

To clearify: The primary question is: What are the arguments for including and excluding the non minified files.

UPDATE:

Just found a solution a nice solution for the auto exclusion. Hers a part of my project file:

<ItemGroup>
  <EmbeddedJavascript Include="MyJavascript.debug.js" />
  <EmbeddedResource Include="MyJavascript.js" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="BeforeBuild">
  <ItemGroup Condition=" '$(Configuration)' != 'Release' ">
    <EmbeddedResource Include="@(EmbeddedJavascript)" />
  </ItemGroup>
  <AjaxMin JsSourceFiles="@(EmbeddedJavascript)" JsSourceExtensionPattern="\.debug\.js$" JsTargetExtension=".js" />
</Target>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文