0

Using ASP.NET MVC3 I am bundling & minifying my React scripts. This is working fine but I am wondering if I can include certain files and exclude others automatically by naming them correctly. I can't seem to find any documentation around this. Here's what I have at the moment in my BundleConfig.cs file:

bundles.Add(new ScriptBundle("~/bundles/react")
    .Include(    
        #if DEBUG
            "~/Scripts/react.debug.js",
            "~/Scripts/react-dom.debug.js",
        #else
            "~/Scripts/react.production.min.js",
            "~/Scripts/react-dom.production.min.js",
        #endif
));

From what I understand, the bundling & minifcation process ignores .min files. Does it have any other rules around .release or .debug files? I've done some initial testing and I believe it still included the .debug file (hard to tell when it's all being minified.

Sam
  • 6,616
  • 8
  • 35
  • 64
  • Is `react.debug.js` and `react.production.min.js` the same (except for the minification)? If so then your not understanding how bundling and minification works (and you should not have and `#if DEBUG`) –  Feb 26 '18 at 06:35
  • Refer [this answer](https://stackoverflow.com/questions/24053519/asp-net-bundling-and-minification-including-already-minified-files-for-product/24054187#24054187) for more detailed explanation –  Feb 26 '18 at 06:36
  • No. Debug contains more verbose errors, additional debugging options etc. – Sam Feb 26 '18 at 10:20

1 Answers1

0

I've done some testing and can't seem to get bundling & minification to do this automatically, so I don't think it's possible to remove this logic.

Sam
  • 6,616
  • 8
  • 35
  • 64