Skip to content

NelsonReis/BundlerMinifier

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bundler and Minifier

A Visual Studio extension that let's you configure bundling and minification of JS, CSS and HTML files.

Build status

Download the extension at the VS Gallery or get the nightly build

Features

  • Bundles CSS, JavaScript or HTML files into a single output file
  • Saving a source file triggers re-bundling automatically
  • MSBuild support for CI scenarios supported
  • Minify individual or bundled CSS, JavaScript and HTML files
  • Minification options for each language is customizable
  • Shows a watermark when opening a generated file
  • Shortcut to update all bundles in solution

Bundling

Select 2 or more of the same type of files in Solution Explorer to create a bundle.

Create bundle

Any edits being made to the source files will instantly produce updated bundle file output.

The bundle configuration is stored in a file called bundleconfig.json which gets added to the root of the project.

Minification

Minify any JS, CSS or HTML file by right-clicking it in Solution Explorer. That will create a <filename>.min.<ext> and nest it under the original file.

Minify file

When the original file is modified, a new min file is produced instantly.

Bundle on build / CI support

In ASP.NET MVC and WebForms projects you can enable bundling and minification as part of the build step. Simply right-click the bundleconfig.json file to enable it.

Bundle on build

Clicking the menu item will prompt you with information about what will happen if you click the OK button.

Bundle on build prompt

A NuGet package will be installed into the packages folder without adding any files to the project itself. thead NuGet package contains an MSBuild task that will run the exact same compilers on the bundleconfig.json file in the root of the project.

Update all bundles

You can run the bundler on all bundleconfig.json files in the solution by using the keyboard shortcut Shift+Alt+i or by using the button on the top level Build menu.

Update all bundles

Source maps

Source maps are supported for JavaScript minification only at this time.

A .map file is produced next to the .min.js file automatically, but if you manually delete the .map file, a new one will not be created on subsequent minifications.

bundleconfig.json

The extension adds a bundleconfig.json file at the root of the project which is used to configure all bundling.

Here's an example of what that file looks like:

[
  {
    "outputFileName": "output/bundle.css",
    "inputFiles": [
      "input/file1.css",
      "input/file2.css"
    ],
    "minify": {
			"enabled": true,
			"commentMode": "all"
    },
    "includeInProject": true,
    "sourceMaps": false
  },
  {
    "outputFileName": "output/all.js",
    "inputFiles": [
      "input/file1.js",
      "input/file2.js"
    ],
    "minify": {
			"enabled": true,
			"termSemicolons": true
    },
    "includeInProject": true,
    "sourceMaps": false
  },
  {
    "outputFileName": "output/app.js",
    "inputFiles": [
      "input/main.js",
      "input/core/" // all .js files in input/core/
    ],
    "minify": {
			"enabled": true,
			"termSemicolons": true
    },
    "includeInProject": true,
    "sourceMaps": false
  }
]

About

Visual Studio extension

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.8%
  • Other 0.2%