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

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

问题描述

我有一个动态生成JavaScript的网站。生成的code介绍类型的元数据和一些服务器端的常量,这样客户可以很容易地消耗服务器提供的服务 - 所以这是非常缓存

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控制器送达;所以它有一个开放的;说〜/ MyGeneratedJs

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

我想加入此JavaScript在JavaScript与其他静态JavaScript文件(如jQuery的等)捆绑:所以就像静态文件,我希望它在调试模式,并与其他文件捆绑缩小的形式分别引用在非调试模式。

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 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天全站免登陆