Saturday, May 11, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
55
rated 0 times [  57] [ 2]  / answers: 1 / hits: 23382  / 12 Years ago, thu, january 17, 2013, 12:00:00

My website is working fine on localhost when @Scripts.Render() is not bundling the scripts however when I deploy to my server the bundled Javascript must contain an error as all Javascript on my page stops working.



Here is my bundle code:



        public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle(~/bundles/jquery).Include(
~/Scripts/jquery-{version}.js,
~/Scripts/jquery-migrate-{version}.js));

bundles.Add(new ScriptBundle(~/bundles/jqueryval).Include(
~/Scripts/jquery.unobtrusive*,
~/Scripts/jquery.validate*));

bundles.Add(new ScriptBundle(~/bundles/jqueryui).Include(
~/Scripts/jquery-ui-{version}.js,
~/Scripts/jquery-ui.unobtrusive-{version}.js));

bundles.Add(new ScriptBundle(~/bundles/modernizr).Include(
~/Scripts/modernizr-*));

bundles.Add(new StyleBundle(~/Content/css).Include(~/Content/site.css));

bundles.Add(new StyleBundle(~/Content/themes/base/css).Include(
~/Content/themes/base/jquery.ui.core.css,
~/Content/themes/base/jquery.ui.resizable.css,
~/Content/themes/base/jquery.ui.selectable.css,
~/Content/themes/base/jquery.ui.accordion.css,
~/Content/themes/base/jquery.ui.autocomplete.css,
~/Content/themes/base/jquery.ui.button.css,
~/Content/themes/base/jquery.ui.dialog.css,
~/Content/themes/base/jquery.ui.slider.css,
~/Content/themes/base/jquery.ui.tabs.css,
~/Content/themes/base/jquery.ui.datepicker.css,
~/Content/themes/base/jquery.ui.progressbar.css,
~/Content/themes/base/jquery.ui.theme.css));
}


Here is my rendering code:



@Styles.Render(~/Content/css)
@Styles.Render(~/Content/themes/base/css)
@Scripts.Render(~/bundles/jquery)
@Scripts.Render(~/bundles/jqueryval)
@Scripts.Render(~/bundles/jqueryui)
@Scripts.Render(~/bundles/modernizr)


Can someone explain what might be happening to my Javascript upon deployment?



Thanks,
Alex.


More From » c#

 Answers
34

You can also change your new ScriptBundle to just new Bundle:



bundles.Add(new Bundle(~/bundles/modernizr).Include(~/Scripts/modernizr-*));


This will bundle your assets without minification. I have run into some cases where minifying just wouldn't work with certain libraries, so this will still allow you to include them in your bundle.


[#80804] Wednesday, January 16, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jacklynr

Total Points: 542
Total Questions: 120
Total Answers: 95

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
;