如何只发布捆绑/缩小的脚本 [英] How to publish only bundled/minified scripts

查看:121
本文介绍了如何只发布捆绑/缩小的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经部署到Azure中的MVC4项目。该捆绑和微小的作品精美绝伦。

I have a MVC4 project that is deployed to Azure. The bundling and minification works absolutely fine.

所有脚本文件都在其中捆绑到一个文件夹/ JS /脚本/ JS

All the script files are in a folder /js which are bundled to /scripts/js

当我使用msdeploy发布到Azure的,我只想部署捆绑/缩小的脚本文件。我不希望任何人通过猜测URL获得访问我的未缩小的脚本。

When I publish to Azure using msdeploy, I would like only the bundled/minified script files to be deployed. I don't want anyone getting access to my un-minified scripts by guessing the url.

据我了解MVC捆绑发生在运行时,因此它需要分拆的文件来创建动态的包。这可能需要与像咕噜进行自动化也许?

I understand MVC bundling happens at runtime hence it would require the unbundled files to create the bundles on the fly. This probably needs to be automated with something like grunt maybe?

想知道是什么部署策略的人在这种情况下使用时,你不想发布非捆绑JS。

Want to know what deploy strategy people use in such cases when you dont want to publish unbundled js.

推荐答案

他们得到您的页面加载脚本,所以我不明白为什么他们看到unminified版本应该是一个大问题,除非也许你有疯狂的或攻击性的评论在unminified版本。用户可以使用JavaScript格式化,像讨论在这个SO张贴以得到缩小的文件回可读格式。

They get your scripts on pageload, so I don't see why them seeing the unminified version should be a big concern, unless maybe you have crazy or offensive comments in your unminified version. Users could use a javascript formatter, like discussed in this SO post to get the minified files back into a readable format.

虽然,对于您的问题,你可以简单地滴在部署 / JS 文件夹中的web.config文件,将你的东西被担任了。在我的测试,这并不会影响微小。但如果你把它放在你的本地文件夹,你就会有错误,在调试模式捆绑(因为调试模式提供了单独的文件,这web.config中保留任何东西从被服务):

Though, for your concerns, you could simply drop a web.config file in the deployed /js folder to keep anything from being served up. In my testing, this did not impact minification. Although if you put it in your local folder, you'll have errors bundling in debug mode (since debug mode serves up the individual files and this web.config keeps anything from being served):

<?xml version="1.0"?>
<configuration>
    <system.web>
        <authorization>
            <deny users="*" />
        </authorization>
    </system.web>
</configuration>

另一个值得关注的是,这取决于你在看到有人在unminified脚本的偏执,您可能需要编写自己的BundleBuilder类为<详细原因href=\"http://stackoverflow.com/questions/21991736/how-to-$p$pvent-user-agent-eureka-1-to-return-source-$c$c\">How以prevent的User-Agent:尤里卡/ 1返回源$ C ​​$ C ,从而揭示用户如何通过改变他们的用户代理查看与评论unminified捆

Another concern is, depending on how paranoid you are at someone seeing an unminified script, you may have to write your own BundleBuilder class for reasons detailed in How to prevent User-Agent: Eureka/1 to return source code, which reveals how users can see unminified bundles with comments by changing their user-agent.

这篇关于如何只发布捆绑/缩小的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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