• Stars
    star
    616
  • Rank 72,837 (Top 2 %)
  • Language
    C#
  • License
    Other
  • Created over 9 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Visual Studio extension

Bundler and Minifier

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

Build status NuGet

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


See the changelog for changes and roadmap and the wiki for more details.

Features

  • Bundles CSS, JavaScript or HTML files into a single output file
  • Saving a source file triggers re-bundling automatically
  • Support for globbing patterns
  • 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
  • Task Runner Explorer integration
  • Command line support
  • Shortcut to update all bundles in solution
  • Suppress output file generation
  • Convert to Gulp

A note about encoding

All files without a BOM (Byte Order Mark) is treated as UTF-8. If you see strange characters in the output bundle files, you may want to consider saving the input files as UTF-8 or an encoding that lets you specify a BOM.

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. That NuGet package contains an MSBuild task that will run the exact same compilers on the bundleconfig.json file in the root of the project.

For ASP.NET Core projects, see the wiki

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.

To enable source maps, add this property to the bundleconfig.json file:

"sourceMap": true

Task Runner Explorer

Get a quick overview of the files you've specified or execute a bundle directly in Task Runner Explorer.

Task Runner Explorer

You can even set bindings so that bundling/minification happens automatically during certain Visual Studio events, such as BeforeBuild and Project Open.

Task Runner Bindings

Suppress output file generation

There are cases when you don't want the extension to listen for file changes and generate bundled and minified output. That could be if you want to use Gulp to use bundleconfig.json or server-side code instead. In those cases it will still be helpful to have the bundleconfig.json file with all the Visual Studio tooling around it, but let other tools handle the bundling and minification process.

To suppress the output, remove the checkbox located in the right-click menu of bundleconfig.json.

Suppress output

Convert to Gulp

This feature makes it easy to start using Gulp based on what's already configured in bundleconfig.json. It will create gulpfile.js and package.json if they don't already exist and then install the needed node modules using npm.

The gulpfile.js will consume bundleconfig.json to get the input and output file paths, but will use regular gulp plugins to do all the bundling and minification. You can modify it to use other plugins without losing its ability to read the bundleconfig.json.

Read more about this and see code samples on the wiki.

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": [
      "css/lib/**/*.css", // globbing patterns are supported
      "css/input/site.css"
    ],
    "minify": {
        "enabled": true,
        "commentMode": "all"
    }
  },
  {
    "outputFileName": "output/all.js",
    "inputFiles": [
      "js/*.js",
      "!js/ignore.js" // start with a ! to exclude files
    ]
  },
  {
    "outputFileName": "output/app.js",
    "inputFiles": [
      "input/main.js",
      "input/core/*.js" // all .js files in input/core/
    ]
  }
]

Contribute

Check out the contribution guidelines if you want to contribute to this project.

For cloning and building this project yourself, make sure to install the Extensibility Tools extension for Visual Studio which enables some features used by this project.

License

Apache 2.0

More Repositories

1

Miniblog.Core

An ASP.NET Core blogging engine
JavaScript
1,466
star
2

WebEssentials2013

Visual Studio extension
C#
949
star
3

MiniBlog

A minimal blog engine using Razor Web Pages
C#
915
star
4

ShortcutExporter

Visual Studio extension
C#
481
star
5

WebCompiler

Visual Studio extension for compiling LESS and Sass files
C#
448
star
6

MarkdownEditor

A Visual Studio extension
C#
397
star
7

WebEssentials.AspNetCore.ServiceWorker

C#
342
star
8

WebEssentials2015

A Visual Studio extension for web developers
C#
302
star
9

AddAnyFile

A Visual Studio extension
C#
256
star
10

Tweakster

A Visual Studio extension
C#
241
star
11

PhotoGallery

ASP.NET Core Photo Gallery
C#
172
star
12

MarkdownEditor2022

A Visual Studio extension
C#
168
star
13

OpenCommandLine

A Visual Studio extension
C#
158
star
14

ExtensibilityTools

Tools for writing Visual Studio extensions
C#
153
star
15

JavaScriptPrettier

A Visual Studio extension
C#
151
star
16

RainbowBraces

A Visual Studio extension
C#
132
star
17

EditorConfigLanguage

A Visual Studio extension
C#
129
star
18

FileDiffer

A Visual Studio extension
C#
128
star
19

TrailingWhitespace

Display trailing whitespace in any VS editor
C#
118
star
20

PrivateGalleryCreator

Create private extension galleries for Visual Studio
C#
118
star
21

FileNesting

Nest files in Solution Explorer
C#
117
star
22

FileIcons

A Visual Studio extension
C#
115
star
23

WebEssentials2012

C#
96
star
24

NpmTaskRunner

Visual Studio extension
C#
88
star
25

TypeScriptDefinitionGenerator

A Visual Studio extension
C#
85
star
26

SolutionColors

A Visual Studio extension
C#
76
star
27

ZenCodingVS

A Visual Studio extension
C#
70
star
28

ExtensionPackTools

A Visual Studio extension
C#
67
star
29

MarkSite

A markdown powered CMS written in ASP.NET
C#
66
star
30

TextmateBundleInstaller

A Visual Studio extension
C#
65
star
31

RestClientVS

C#
65
star
32

ShowTheShortcut

A Visual Studio extension
C#
65
star
33

PackageInstaller

A Visual Studio extension
C#
64
star
34

CodeCleanupOnSave

C#
62
star
35

VuePack

C#
61
star
36

OpenInVsCode

A Visual Studio extension
C#
61
star
37

WebAnalyzer

A Visual Studio extension
C#
55
star
38

WebEssentials.AspNetCore.OutputCaching

C#
53
star
39

CommentRemover

A Visual Studio extension
C#
51
star
40

WebEssentials.AspNetCore.CdnTagHelpers

A CDN helper for ASP.NET Core
C#
49
star
41

WebEssentials2019

C#
49
star
42

ImageOptimizerWebJob

C#
47
star
43

DialToolsForVS

A Visual Studio extension
C#
47
star
44

ReverseProxyCDN

C#
42
star
45

CommandTaskRunner

A Visual Studio extension
C#
42
star
46

JSON-Intellisense

NPM package Intellisense in package.json
C#
40
star
47

WebPackTaskRunner

A Visual Studio extension
C#
40
star
48

VuePack2017

A Visual Studio extension
C#
38
star
49

AspNetCoreTemplatePack

C#
38
star
50

SolutionExtensions

A Visual Studio extension
C#
36
star
51

FeedCollector

A simple website for aggregating RSS/Atom feeds
C#
36
star
52

WebAccessibilityChecker

A Visual Studio extension
C#
34
star
53

VsixGallery

The Open VSIX Gallery
C#
34
star
54

ClearComponentCache

A Visual Studio extension
C#
33
star
55

Surrounder

A Visual Studio extension
C#
33
star
56

PrettyPaste

Fixes the added blank lines when copying and pasting from IE
C#
32
star
57

ImageSprites

A Visual Studio extension
C#
32
star
58

Editorsk

A Visual Studio extension
C#
30
star
59

JavaScriptSnippetPack

A Visual Studio extension
Vim Snippet
30
star
60

CloseAllTabs

A Visual Studio extension
C#
30
star
61

WorkspaceFiles

C#
30
star
62

IgnoreFiles

A Visual Studio extension
C#
29
star
63

DarkTheme2019

C#
29
star
64

zencoding

Provides hybrid ZenCoding for Web Essentials
C#
29
star
65

CommandTableInfo

A Visual Studio extension
C#
29
star
66

Madskristensen.VisualStudio.SDK

Visual Studio SDK meta packages
29
star
67

ImagePreview

C#
28
star
68

ExtensionGallery

A Visual Studio extension gallery
C#
28
star
69

Packman

A client-side package manager
C#
28
star
70

KnownMonikersExplorer

A Visual Studio extension
C#
28
star
71

SvgViewer

Shows the rendered image of .svg files
C#
27
star
72

SqlFormatter

C#
27
star
73

TemplateCreator

A Visual Studio extension
C#
27
star
74

BasicEssentials

26
star
75

DeveloperNews

C#
26
star
76

BrowserReloadOnSave

A Visual Studio extension
C#
26
star
77

StaticWebHelper

Perf optimize static websites hosted on IIS
C#
25
star
78

MIDL

A Visual Studio extension
C#
24
star
79

Community.VisualStudio.Toolkit

A community toolkit for writing Visual Studio extensions
C#
24
star
80

vswebessentials.com

The official website of Web Essentials for Visual Studio
C#
23
star
81

ExtensionUpdater

Visual Studio extension for auto updating extensions
C#
23
star
82

CssTools

A Visual Studio extension
C#
22
star
83

ExtensionScripts

PowerShell
22
star
84

InsertGuid

A Visual Studio extension
C#
22
star
85

CopyNice

A Visual Studio extension
C#
22
star
86

ErrorHighlighter

Visual Studio extension
C#
21
star
87

EditorColorPreview

C#
21
star
88

JsonSchemaGenerator

A Visual Studio extension
C#
20
star
89

SpaTemplatePack

A Visual Studio extension
C#
20
star
90

VsctIntellisense

Intellisense for VSCT files
C#
20
star
91

Madskristensen.VisualStudio.SDK.HelpersOLD

C#
19
star
92

PkgdefLanguage

A Visual Studio extension
C#
19
star
93

JavaScriptRegions

A Visual Studio extension
C#
19
star
94

OptionsSample

A Visual Studio extension sample
C#
19
star
95

GitHubThemes

C#
18
star
96

WebEssentialsChrome

A browser extension
JavaScript
18
star
97

OutputWindowFilter

C#
17
star
98

MiniBlogFormatter

C#
17
star
99

ShowKeybindings

A Visual Studio extension
HTML
17
star
100

GitPull

Easy way to "git pull" in Visual Studio
C#
16
star