[英]ASP.Net MVC Bundler not including my .min file in Release
I have an issue with the mvc4 bundler not including a file with extension .min.js. 我遇到了mvc4捆绑软件不包含扩展名为.min.js的文件的问题。 In my Scripts folder i have two files: bootstrap.js, bootstrap.min.js
在我的Scripts文件夹中,我有两个文件:bootstrap.js,bootstrap.min.js
In my BundleConfig class, I declare 在我的BundleConfig类中,我声明
#if !DEBUG
BundleTable.EnableOptimizations = true;
#endif
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap.js"));
When running in Debug it renders as expected: 在Debug中运行时,它将按预期方式呈现:
<script src="/Scripts/bootstrap.js"></script>
When running in Release it renders as: 在Release中运行时,它呈现为:
<script src="/bundles/bootstrap?v=57XuMf8ytOYgVErEDhgFDRtQ5jlC48bryka4m2DVq_M1"></script>
Why doesn't it render as: 为什么不将其渲染为:
<script src="/Scripts/bootstrap.min.js"></script>
Why doesn't it render as:
<script src="/Scripts/bootstrap.min.js"></script>
为什么不将其呈现为:
<script src="/Scripts/bootstrap.min.js"></script>
Because that's how bundling works in ASP.NET MVC 4. Don't worry, the contents of this /bundles/bootstrap?v=57XuMf8ytOYgVErEDhgFDRtQ5jlC48bryka4m2DVq_M1
is exactly the contents of the /Scripts/bootstrap.min.js
. 因为这就是捆绑在ASP.NET MVC 4中的工作方式。不用担心,此
/bundles/bootstrap?v=57XuMf8ytOYgVErEDhgFDRtQ5jlC48bryka4m2DVq_M1
的内容正是/Scripts/bootstrap.min.js
的内容。 In this case the bundling mechanism hasn't minified the /Scripts/bootstrap.js
file but used the already minified version. 在这种情况下,捆绑机制并未缩小
/Scripts/bootstrap.js
文件,而是使用了已经缩小的版本。
The reason you want to use bundles. 您要使用捆绑软件的原因。
By default, when you're in debug mode (you can modify your Web.config to set if enable DEBUG), the js/css files will not be bundled, so you can see the files seperately which will make it easier to debug. 默认情况下,当您处于调试模式时(可以将Web.config修改为启用DEBUG的情况下进行设置),js / css文件不会被捆绑在一起,因此您可以单独查看文件,这将使调试更加容易。
When it's not debug enabled, the files will be bundled. 如果未启用调试,则文件将被捆绑。
So if you already have .min.js files, you can import them directly in your page. 因此,如果您已经拥有.min.js文件,则可以将其直接导入页面中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.