Bundling is a way or technique to combine multiple JavaScript or CSS files into a single file. Minification is a technique to reduce the size of the file by removing white space and commented code. Both Bundling and Minification are used to improve the performance of our web application by reducing the number of requests to the Server and reducing the size of the requested assets, such as JavaScript and CSS files.
- Bundles CSS, JavaScript, or HTML files into a single output file.
- Minify individual or bundled CSS, JavaScript, and HTML files.
- Saving a source file triggers re-bundling automatically.
- Support for globbing patterns.
- MSBuild support for CI scenarios supported.
- Minification options for each language are customizable.
- Shows a watermark when opening a generated file.
- Task Runner Explorer integration.
- Command line support.
- Shortcut to update all bundles in solution.
- Suppress output file generation.
- Convert to Gulp.

- [
- {
- "outputFileName": "wwwroot/js/site.min.js",
- "inputFiles": [
- "wwwroot/js/test1.js",
- "wwwroot/js/test.js",
- "wwwroot/js/test2.js"
- ]
- }
- ]
We can run all bundles defined in bundleconfig.json files in the solution by clicking "Build >> Update All Bundles" or using shortcut key "Shift + Atl + l".
A .map file is produced after producing .min.js file automatically. We can create this map file on subsequent minifications. To enable generating source map, we need to assign property "sourceMap" to true in bundleconfig.json file.
- [
- {
- "outputFileName": "wwwroot/js/site.min.js",
- "inputFiles": [
- "wwwroot/js/test.js",
- "wwwroot/js/test1.js",
- "wwwroot/js/test2.js"
- ],
- "sourceMap": true
- }
- ]
We can also execute a bundle using Visual Studio Task Runner. Task Runner is located at Tools menu in VS 2015. When you open task runner, it shows bundles under the bundleconfig.json node.
This extension also allows us to move onto gulp with an existing project. It will create package.json and gulpfile.js if they do not exist.
This extension also allows us to bundle and minify files using command line. Following commands are supported
- dotnet bundle
This command executes all the bundled command that were defined in bundleconfig.json file for minifying and bundling specific files.
- otnet bundle clean
This command clears all the existing output files from the disk
- dotnet bundle watch
It creates a watcher which will automatically run the "dotnet bundle" commnad when any input file define in the bundleconfig.json is changed.
- dotnet budle help
It displays the available help options.
Using this extension, we can bundle and minify the JavaScript, CSS and HTML without written any code. This extension also supports command line and we can also bind the bundle and minify commands with any Visual studio event.

Viknaraj ManogararajahPosted Jul 21, 2018, 9:45 AM
nice article, thank you for sharing
J DPosted Jul 17, 2018, 9:58 AM
When i publish, it publishes both .css and min.css files. Why ? and how do i know if in real server send only min.css files. ? any idea ?
Colin NgPosted Sep 27, 2017, 10:26 PM
Thanks for your article! Just wanted to contribute back by pointing out some typos near the end, under Support for Command line: otnet bundle clean, commnad, dotnet budle help.
Vishal PrajapatiPosted Feb 22, 2017, 11:02 PM
Worth reading..Thanks for sharing
Nilesh ShahPosted Feb 22, 2017, 3:47 PM
Good explanation J.T.