bundling-and-minification

How to add bundling and minification to an ASP.NET MVC project?

≯℡__Kan透↙ 提交于 2019-12-24 07:28:05
问题 I have just upgraded an ASP.NET MVC 3 project to MVC 4, and am now trying to add bundling and minification facilities to it. So far I have installed Microsoft ASP.NET Web Optimization Framework via NuGet and added System.Web.Optimization among the Razor namespaces in Web.config: <system.web> ... <pages> <namespaces> ... <add namespace="System.Web.Optimization" /> ... </namespaces> </pages> ... </system.web> However, @Styles and @Scripts are still not directly accessible in my Razor views (*

ASP.NET Mvc 4 Use bundle's benefits for Url.Content

和自甴很熟 提交于 2019-12-24 03:36:05
问题 Is there any way I can do this? Some of the benefits of bundling are: Minimization Gzip compression The request has a token parameter for handling files versiones (cache). In my site I use a lot of bundles, but in some pages I only have 1 script and I don't think I should create a bundle only for 1 script. Is there any way I can use this three benefits with Url.Content method. My utopic solution would be to set up something (maybe in the web.config) and whenever Url.Content is called it adds

How to simultaneously create both 'web' and 'node' versions of a bundle with Webpack?

我只是一个虾纸丫 提交于 2019-12-24 00:37:28
问题 Is there a way to create both 'web' and 'node' versions of a bundle with one go by using Webpack or Browserify? The 'web' version of the bundle will be used on a client, and 'node' version of the same bundle will be used on the server for pre-rendering ("isomorphic" web application). 回答1: I think the easiest way is probably just to create two configs, one with target: "node" and the other target: "web" in the configuration, and run them both like $ webpack && webpack --config webpack.config

MVC4 Bundling: where the URL for bundle is held

橙三吉。 提交于 2019-12-23 20:22:00
问题 When the bundle is registered in MVC4, what is responsible for "intercepting" incoming http requests for /bundles/someBundle?v=1hDzBpmYJm4Iu-OjRN1YqS1WeNThVl0kStLJGP8WCr41 ? also since hash for each bundle is calculated only once (at a first request), where is that actually held, - and is it possible to return 404 if an incoming hash does not match 回答1: what is responsible for "intercepting" incoming http requests for ~/bundles/someBundle There are no incoming requests to ~/bundles/someBundle

How can I still run a custom IBundleTransform when EnableOptimization is off in ASP.NET?

徘徊边缘 提交于 2019-12-23 19:07:48
问题 First the background - I'm using Handlebars for templating HTML and I want to make use of the bundling and caching capabilities of ASP.NET Bundling to deliver the templates to the client. To that end I've created my own Bundle subclass and an implementation of IBundleTransform that does some necessary conversion of my templates. In particular I: add the templates to visual studio as HTML but embed the template in a <script type='text/x-handlebars-template'>...</script> which seems to give me

Did Auto-Bundling/Minification Get Tossed in Final Release of MVC 4?

拥有回忆 提交于 2019-12-23 12:14:14
问题 According to an article I read earlier by Scott Guthrie, and a video posted by Mads Kristensen, I should be able to auto-bundle/minify in ASP.net MVC 4 by replacing this: <link href="Styles/reset.css" rel="stylesheet" type="text/css" /> <link href="Styles/normalize.css" rel="stylesheet" type="text/css" /> <link href="Styles/styles.css" rel="stylesheet" type="text/css" /> <script src="Scripts/jquery-1.8.0.min.js" type="text/javascript"></script> <script src="Scripts/jquery-validation.min.js"

JavaScript Error in Asp.Net MVC 4 Bundling

久未见 提交于 2019-12-23 11:45:13
问题 When I use the below Bundling in MVC 4, my App gets several JavaScript errors,such as 'jQuery undefined' bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js", "~/Scripts/jquery-ui-{version}.js", "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*")); But when I use the below approach, my App works without JavaScript errors: bundles.Add(new ScriptBundle("~/bundles/jquery1").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~

Migrating ASP.NET MVC 5 bundling “versions” to MVC 6

。_饼干妹妹 提交于 2019-12-23 09:31:59
问题 The bundling feature is excluded from MVC 6 and the suggested method is to do bundling using gulp tasks. Using bundling we used to get a random string at the end of the included css/javascript file url(s). This string was very important because once you changed anything in your css/javascript then a new string would be generated which would force browsers to load the new version(s) of the file(s). So if you had 3 css files they would be bundled into one and they would look like this: <link

How can I get the original line number and symbol from a sourcemap

ⅰ亾dé卋堺 提交于 2019-12-23 07:46:25
问题 I'm logging javascript errors from my site, but the files are minimized so I don't get meaningful line numbers. I do have source maps, however. Is there a service, script, npm module, or anything that can help me "translate" the line numbers from the minified versions into something useful? 回答1: I have found the answer using this npm module: https://www.npmjs.org/package/source-map Edit Feb 1st, 2015 Found the following project which handles this: https://github.com/epeli/source-map-peek 来源:

Bundling JavaScript courses Uncaught SyntaxError: Unexpected token <

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 06:45:42
问题 Using the bundle feature of mvc4 courses Uncaught SyntaxError: Unexpected token < on loading. With debug="true" everything is works like excepted. How can i solve the error or can i disable the bundle feature just for scripts? Solved Renamed the bundle name to not match up with any directory 回答1: Before you can answer the question of what caused this error, you must first figure out where the error occurred. The only difference in the syntax of your code when bundled is that it is minified. A