Is there any way to make the bundling and minification process in an ASP.NET MVC-application perform a "search and replace" inside the script files before it minifies them?
As Vladimir said, you can create your own Bundle transformation, simply implementing
IBundleTransform. I have written a blog post about bundling and minifying Coffeescripts that can point you in the right direction : http://tallmaris.com/advanced-bundling-and-minification-of-coffeescripts-in-mvc4/
In summary, create a custom transform like this:
Then in your
var myBundle = new Bundle("~/Scripts/localised") .Include("~/JsToLocalise/*.js"); //your JS location here, or include one by one if order is important. myBundle.Transforms.Add(new MultiLanguageBundler()); myBundle.Transforms.Add(new JsMinify()); bundles.Add(myBundle);
You may need to tweak a few things but let me know if it helps you.
IBundleTransform interface. Example can be found here.
©2020 All rights reserved.