ASP.NET 捆绑/缩小:包括动态生成的 Javascript [英] ASP.NET bundling/minification: including dynamically generated Javascript

查看:21
本文介绍了ASP.NET 捆绑/缩小:包括动态生成的 Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态生成 Javascript 的站点.生成的代码描述了类型元数据和一些服务器端常量,以便客户端可以轻松使用服务器的服务 - 因此它非常可缓存.

I have a site that dynamically generates Javascript. The generated code describes type-metadata and some server-side constants so that the clients can easily consume the server's services - so it's very cacheable.

生成的 Javascript 由 ASP.NET MVC 控制器提供;所以它有一个 Uri;说 ~/MyGeneratedJs.

The generated Javascript is served by an ASP.NET MVC controller; so it has a Uri; say ~/MyGeneratedJs.

我想将此 Javascript 与其他静态 Javascript 文件(例如 jQuery 等)一起包含在 Javascript 包中:所以就像静态文件一样,我希望它在调试模式下单独引用,并以与其他文件捆绑的缩小形式进行引用在非调试模式下.

I'd like to include this Javascript in a Javascript bundle with other static Javascript files (e.g. jQuery etc): so just like static files I want it to be referenced separately in debug mode and in minified form bundled with the other files in non-debug mode.

如何在包中包含动态生成的 Javascript?

How can I include dynamically generated Javascript in a bundle?

推荐答案

Darin 是对的,目前捆绑仅适用于静态文件.但是,如果您可以添加具有最新内容的占位符文件,则捆绑会设置文件更改通知,该通知会在占位符文件更改时自动检测.

Darin is right, currently bundling only works on static files. But if you can add a placeholder file with up to date content, bundling does setup file change notifications which will detect automatically when the placeholder file changes.

此外,我们将很快转向使用 VirtualPathProviders,这可能是一种提供动态生成内容的方式.

Also we are going to be moving to using VirtualPathProviders soon which might be a way to serve dynamically generated content.

更新: 1.1-alpha1 版本现已发布,支持 VPP

Update: The 1.1-alpha1 release is out now which has support for VPP

这篇关于ASP.NET 捆绑/缩小:包括动态生成的 Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆