I wrote a new app, which will use an existing theme, which is going to be changed by designer.
So I decided, instead of putting scripts in Scripts and everything else in Content (Css, images), to just keep the theme in Theme folder (with subdirs - js, css, img)
So I try to change the scripts bundling to point to my scripts in Theme/js instead of Scripts
I changed it to
bundles.Add(
new ScriptBundle("~/Scripts/vendor")
.Include("~/Theme/js/jquery-{version}.js")
.Include("~/Theme/js/knockout-{version}.debug.js")
.Include("~/Theme/js/sammy-{version}.js")
.Include("~/Theme/js/toastr.js")
.Include("~/Theme/js/Q.js")
.Include("~/Theme/js/breeze.debug.js")
.Include("~/Theme/js/bootstrap.js")
.Include("~/Theme/js/moment.js")
);
What I don't understand is line
new ScriptBundle("~/Scripts/vendor")
If I leave it this as above (even if there is no Scripts/vendor folder, code works ok, but f I change it to
new ScriptBundle("~/Theme/js/vendor")
I get network error in firebug:
"NetworkError: 404 Not Found - http://localhost:51154/scripts/vendor"
and rest of the scripts are not loaded.
What that line does?
Thanks
The bundles.Add(ScriptBundle)
method adds a script bundle to the bundles table, to which you can refer by the string provided to the ScriptBundle(string)
constructor.
So a bundle created with new ScriptBundle("~/Foo")
and added to bundles
, can later be rendered using @Scripts.Render("~/Foo")
.
What you probably forgot is to change @Scripts.Render("~/Scripts/vendor")
in your _layout.cshtml to @Scripts.Render("~/Theme/js/vendor")
, and that will be the error you saw.
The parameter you pass to the constructor is merely documented as "a virtual path for the bundle", so you'll have to figure out what that means and what you can and cannot put there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With