.NET Core MVC Bundling - Is there an equivalent to System.Web.Optimization.BundleTable.EnableOptimizations = false in ASP.NET MVC Core?

Viewed 3228

I want to run my application in debug mode without any bundling or minification. In ASP.NET MVC (Framework), I could use System.Web.Optimization.BundleTable.EnableOptimizations = false and the paths to the source files were output individually.

Is there anyway to achieve the same effect in .NET Core

Alternatively, the capability to trigger bundling on file save would help as well.

2 Answers

There is a nuget package manager for Dotnet core available in the following url: Nuget

Using Package Manager: Install-Package DotFramework.Core.Web.Optimization -Version 3.12.0

Using CLI: dotnet add package DotFramework.Core.Web.Optimization --version 3.12.0

You could create a bundleconfig.json file, something like this:

[
  {
    "outputFileName": "wwwroot/css/site.min.css",
    "inputFiles": [
      "wwwroot/css/site.css"
    ]
  },
  {
    "outputFileName": "wwwroot/js/site.min.js",
    "inputFiles": [
      "wwwroot/js/site.js"
    ],
    "minify": {
      "enabled": true,
      "renameLocals": true
    },
    "sourceMap": false
  }
]

I m not completely sure about this but its probably possible set different configurations of the bundle depending on the environment.

For more details follow this tutorial: https://docs.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-2.2&tabs=visual-studio

Or

If you are referring to the bundles, scripts etc in your layout view to only run in specific modes, again this can be configured to run only in certain environments.

Related