bundling-and-minification

ASP.Net MVC 5 sub-directory bundling issues

廉价感情. 提交于 2019-12-01 00:00:37
问题 I am seeing a weird behavior with bundling in my ASP.Net MVC 5 project. My project works just fine when I explicitly declare all the files in my BundleConfig.cs file as follows: bundles.Add(new ScriptBundle("~/bundles/app").Include( "~/app/app.js", "~/app/config.js", "~/app/dir1/file1.js", "~/app/dir1/subdir1/file2.js", ..... However, if I switch to use IncludeDirectory instead, the script paths during development ( BundleTable.EnableOptimizations = false ) are not complete. This is what I

BundleTable.Bundles.GetBundleFor() returns but not Items inside

南楼画角 提交于 2019-11-30 23:14:16
Briefly: Bundles which contain items from a VirtualPath (Served by custom VirtualPathProvider) don't work. Hash isn't generated in the v= and resolving them shows the .Items property as empty. Detailed: Suppose we have a bundle registration: bundles.Clear(); bundles.ResetAll(); BundleTable.EnableOptimizations = true; bundles.Add(new StyleBundle("~/bundles/css") .Include("~/Content/site.css")); bundles.Add(new StyleBundle("~/bundles/admin/somestyle") .Include("~/Areas/Admin/Content/css/aaa2.css")); Some notes here: ~/bundles/admin/somestyle physically doesn't exist. ~/Areas/Admin/Content/css

How to manage ASP.NET Core bundleconfig.json for multiple environments?

孤人 提交于 2019-11-30 21:12:15
What's the best practice for using the ASP.NET Core bundleconfig.json with development versus production environments? The prior bundler ( BundleCollection ) would pay attention to the DEBUG compiler directive and not minify the list of scripts when you're debugging. It appears as though the new paradigm is to have <environment> tags in the HTML templates that test for the ASPNETCORE_ENVIRONMENT value. Though I don't see a way of incorporating that environment variable into the bundleconfig.json workflow. One way I see is to maintain 2 lists for each bundle output in bundleconfig.json ,

Is there an easy way to render absolute URLs with Microsoft Web Optimization framework / script bundling?

旧城冷巷雨未停 提交于 2019-11-30 18:32:58
I'm trying to render a JavaScript bundle using Microsoft's Web Optimization framework, like this: @Scripts.Render("~/assets/bundle.js") And building a small bundle, like this: public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/assets/bundle.js") .Include( "~/scripts/jquery-2.1.0.min.js", "~/scripts/somescript.js" )); ... } But when optimizations are on, it only renders a relative URL, like this: <script src="/assets/bundle.js?v=mGDOiNaiTrSfcNq41OoA7A_BcN8PrXuMbfl-TE84HVY1"></script> How can I have script bundling render an absolute URL instead? I

Bundle Minification not working when publishing WebForms App

♀尐吖头ヾ 提交于 2019-11-30 17:32:14
I'm trying to use bundle minification for some .css and .js files. My bundle config is the following: public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/Modernizr").Include( "~/Scripts/modernizr.js" )); bundles.Add(new StyleBundle("~/TemplateContent").Include( "~/Content/bootstrap.css", "~/Content/bootstrap-responsive.css", "~/Content/prettyPhoto.css", "~/Content/prettify.css", "~/Content/flexslider.css", "~/Content/iview.css", "~/Content/style.css", "~/Content/default.css" )); bundles.Add(new StyleBundle("~/AppContent").Include( "~/Content/bootstrap

Could not load file or assembly 'WebGrease' one of its dependencies. The located assembly's manifest definition does not match the assembly reference

老子叫甜甜 提交于 2019-11-30 17:18:42
This issue has many solutions, please read all answers below, they might help you solve your problem too. If you find a new way to solve this, please document in your answer I am trying to add System.Web.Optimization to my ASP.NET Web Forms solution. I added Microsoft ASP.NET Web Optimization Framework through NuGet Packages. It added Microsoft.Web.Infrastracture and WebGrease (1.5.2) to the references. However, when I run <%= System.Web.Optimization.Scripts.Render("~/bundles/js")%> I get runtime error Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral,

Webpack Uglify causes routing to stop work

北慕城南 提交于 2019-11-30 16:39:54
When I uglify webpack bundle, routing stops work without any error message or log message. I am using oclazyload to lazy load. Route.js module.exports = function(app) { var routeConfig = function($stateProvider) { $stateProvider .state('home', { url: '/', templateUrl: 'app/dashboard/dashboard.min.html', title: 'Home', ncyBreadcrumb: { label: 'Home' } }) .state('organizationStructure', { url: '/organizationStructure', templateUrl: 'app/admin/organizationStructure/manageHierarchy/manageHierarchyShell.min.html', 'abstract': true, ncyBreadcrumb: { skip: true }, resolve: ['$q', '$ocLazyLoad',

Create a Script bundle from multiple locations

自作多情 提交于 2019-11-30 12:34:41
Let's assume our app is offline, i.e. we can't use 3rd party CDNs thus we're creating our own. I'd like to host all of the vendor scripts in a separate (Parent) web app and then include them in the bundles in several other MVC Apps. e.g. http://localhost/parentWeb/Scripts/jquery.js http://localhost/parentWeb/Scripts/jquery-ui.js http://localhost/parentWeb/Scripts/globalize.js I'd like to include in the ASP.NET MVC App Website located in: http://localhost/parentWeb/childWeb i.e. do something like this: bundles.UseCdn = true; bundles.Add( new ScriptBundle( "~/bundles/VendorScripts", "http:/

How do I use react.js without a bundler?

守給你的承諾、 提交于 2019-11-30 12:24:25
Recently I have been playing around with react.js and I like the speed that I can develop working UI components. I have now created quite a few components and I would like to distribute some of them among different .jsx files. Every thing I've read says that I should be using a bundler like browserify or webpacker whenever moving to production. However I am against this idea. Part of the reason I like developing in javascript is because its a scripted language and there is no compiler to muck around with. If I wanted to mess around with build chains and the like I would probably just do my

Make ASP.NET bundling specify media=screen for CSS bundle

ⅰ亾dé卋堺 提交于 2019-11-30 10:28:33
问题 I'm just trying out ASP.NET 4.5 bundling and minification, and ran into an issue. I've got around 10 css files, of which 2 were originally referenced in the layout using the attribute media="screen". Since the syntax for adding a css to the bundle does not let you specify that such attribute should be added (makes sense, since the attribute would apply for the whole bundle), I was hoping to see an overload of @Styles.Render that would allow me to specify html attributes, like in other Html