Ok so I have been using the C# bundling to minify and combine scripts and css.
But I'm not sure how to append a script to a bundle which has already been created.
I'm trying to append to the bundle because not all scripts are found in the same file, as I'm working with a nopcommerce solution in visual studio. So the scripts are added all over the solution.
Here is the bundle code:
bundles.Add(new ScriptBundle("~/Content/themes/base/js/scripts/footeroptimized").Include(
"~/Themes/MyTheme/Content/js/bootstrap.min.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.min.js",
"~/Scripts/public.common.min.js",
"~/Themes/MyTheme/Content/js/readmore.min.js"));
I thought maybe I could use the bundles .Add() function but I get an error:
bundles.Add("~/Themes/MyTheme/Content/js/global.min.js"));
The error is: "Cannot convert from string to system.web.optimization.bundle"
I couldn't find anything explaining why im getting that error.
Also I have added the using statement for optimizations @using System.Web.Optimization;
Anyone know how to add to a bundle which has already been created.
UPDATE:
I have also tried the following but it doesn't work:
var footerScriptBundle = new ScriptBundle("~/Content/themes/base/js/scripts/footeroptimized");
footerScriptBundle.Include(
"~/Themes/MyTheme/Content/js/bootstrap.min.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.min.js",
"~/Scripts/public.common.min.js",
"~/Themes/MyTheme/Content/js/readmore.min.js");
footerScriptBundle.Include("~/Themes/MyTheme/Content/js/global.min.js");
Cheers
global.min.jsat the same time as you create the ScriptBundle the first time.