Wednesday, 15 April 2015

javascript - MVC Bundling Not Working -



javascript - MVC Bundling Not Working -

i working on little mvc project, have declared bundle in bundleconfig.cs this

//javascript bundle

bundles.add(new scriptbundle("~/bundles/layout1js").include( "~/content/public/js/jquery.min.js", "~/content/public/js/bootstrap.min.js", "~/content/public/js/jquery.isotope.min.js", "~/content/public/js/jquery.photo.js", "~/content/public/js/easing.js", "~/content/public/js/jquery.lazyload.js", "~/content/public/js/jquery.ui.totop.js", "~/content/public/js/nav.js", "~/content/public/js/sender.js", "~/content/public/js/jquery.slider-min.js", "~/content/public/js/custom.js")); //css bundle bundles.add(new stylebundle("~/content/public/css").include( "~/content/public/css/main.css"));

in _layout.cshml in head section have entered:

<head> <meta charset="utf-8"> <title>test</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- load css files --> @styles.render("~/content/public/css", "~/content/css") <!-- load js files --> @scripts.render("~/bundles/layout1js") </head>

in application_start have:

bundletable.enableoptimizations = true;

and web.config

<compilation debug="true" targetframework="4.0">

this gave me bit of headache trying figure why bundling isnt working specially javascript. 1 please advise

the bundling not working because of line

<compilation debug="true" targetframework="4.0">

when in debug, bundles not compress or minify "debugging" , beingness able see actual javascript , css thing when debugging. when have debug set false (or removed tag), application running in release mode. bundling occur @ point (unless set bundletable.enableoptimizations = false;)

<compilation debug="false" targetframework="4.0">

or

<compilation targetframework="4.0">

as pointed out mike below, bundletable.enableoptimizations = true; should override web.config setting. however, may still out of debug mode in case project not overriding setting.

javascript css asp.net-mvc-4 model-view-controller bundle

No comments:

Post a Comment