Bundling and Minification in ASP.NET Core
The file is self explantory, you can specify multiple file in the inputFiles element, which will be combined and minified based on the minify element. Now you can combine and minify using “dotnet bundle” command. Here is the output when I run the dotnet bundle command on my MVC project.
You can integrate it to the development lifecycle by adding the dotnet build command in the “precompile” script section in project.json file. If you are using Yo ASP.NET generator, the project template will be using precompile script section in project.json.
There are few more commands also available with dotnet bundle tool.
- dotnet bundle clean - Executing dotnet bundle clean will delete all output files from disk.
- dotnet bundle watch - To automatically run the bundler when input files change, call dotnet bundle watch. This will monitor any file changes to input files in the working directory and execute the bundler automatically.
- dotnet bundle help - Get help on how to use the CLI.
If you are using Visual Studio, you can get more information about Bundling and Minification here
Happy Programming :)