I have many scripts and css that I wrote in my MVC project.
I'm using Bundling and Minification and I know I can bundle them all togther like this:
bundles.Add(new StyleBundle("~/Content/site/").Include("~/Content/site/*.css"));
bundles.Add(new ScriptBundle("~/bundles/site").Include("~/Scripts/site/*.js"));
The problem is that I don't want to Render all the scripts and css together, I need one or two in each View, I know that I can manually register each script/css and then I will be able to render them separately in each View:
bundles.Add(new ScriptBundle("~/bundles/script1").Include("~/Scripts/site/script1.js"));
bundles.Add(new ScriptBundle("~/bundles/script2").Include("~/Scripts/site/script2.js"));
And then in one View:
@section scripts{
@Scripts.Render("~/bundles/script1")
}
And in the second one:
@section scripts{
@Scripts.Render("~/bundles/script2")
}
My question is if this is correct or there is a better solution for that.