<commit_before># Bundler

Bundler is a fast, command-line tool (easily integrated into existing IDEs, inc VS.NET) that statically **compiles**, **minifies** and **combines** your websites **less**, **sass**, **css**, **coffeescript** and **js** files.

  - All bundling is done at **compile time** with a build-step so no dependencies needed at runtime. 
  - Can be used with any website project (ie. not only .NET). Includes a **windows** node.exe although all scripts work cross-platform.
  - Includes a single C# **MvcBundler.cs** class with extension methods to seamlessly integrate it with any **ASP.NET MVC** website.
  - Runs outside the context of your ASP.NET MVC website so client scripts can be re-compiled **without restarting** your C# project.
  - Uses a self-contained **node.exe** for all compilation & minification - designed for maximum runtime and compile time performance.
  - Doesn't use any compiled dlls or .exe's (excl node.exe) and includes source code for everything so can easily be read and extended.

## Extremely fast at both Build and Runtime
Bundler is extremely fast - uses Googles leading V8 JavaScript engine (inside node.exe). All build scripts use only *pure JavaScript* implementations (uglifyjs, coffee-script, clean-css, etc) allowing all compilation and minification to run in a single process. 

#### Async / Non-Blocking
The packager is completely **async and non-blocking** - allowing the processing inside each bundle to happen in parallel. 

#### No Runtime overhead
Designed for maximum runtime performance since no compilation/minification happens at runtime. 
Even the generated HTML output is cached in memory (in production mode) - so has effectively no runtime overhead.

## How it works

You define css or js **bundles** (in plain text) that specifies the list of files you wish to bundle together. Running **bundler.cmd** (either as a short-cut key or post-build script) will scan through your **/Content** folder finding all defined **.js.bundle** and **.css.bundle** definition files which it goes through, only compiling and minifying new or modified files.

## Install

To run you just need a copy of **/bundler** folder in your website host directory. This can be done by cloning this repo or installing via NuGet:

[![Install-Pacakage ServiceStack.Host.Mvc](http://www.servicestack.net/img/nuget-bundler.png)](https://nuget.org/packages/Bundler)

*Once installed you can optionally exclude the '/bundler' or '/bundler/node_modules' folders from your VS.NET project since they contain a lot of files (not required to be referenced).*

By default bundler looks at **/Content** and **/Scripts** project folders - this can be changed by editing [/bundler/bundler.cmd](https://github.com/ServiceStack/Bundler/blob/master/NuGet/content/bundler/bundler.cmd):

    node bundler.js ../Content ../Scripts

Now you can define .bundles in any of the above folders. For illustration an example **app.js.bundle** and **app.css.bundle** text files are defined below:

**/Scripts/app.js.bundle**

	js/underscore.js
	js/backbone.js
	js/includes.js
	js/functions.coffee
	js/base.coffee
	bootstrap.js

**/Content/app.css.bundle**
	
	css/reset.css
	css/variables.less
	css/styles.less
	css/sassy.sass
	default.css

Now everytime you run **/bundler/bundler.cmd** it will scan these files, compiling and minifying any new or changed files. 

**Bundle file options**

Options can be specified to alter how your files are processed.  Options must be specified on the first line of the bundle file and the line must start with `#options `.

    #options nobundle
    css/reset.css
    css/variables.less
    default.css

The currently available options are:

1. **nobundle**: compiles and minifies all files listed, however it does not bundle them into a single file.  This allows you to compile and minify your standalone files without bundling them into another file.

Tip: For greater productivity integrate it with VS.NET by assiging a keyboard short-cut to **bundler.cmd** or run it as a post-build script so it's easily re-run it when your files have changed.

#### Create an External Tool inside VS.NET:

Allows you to run **Alt T + B** (or assign your own short-cut) to re-compile and minify your changed assets without re-building your project:

![Add External Tool in VS.NET](http://www.servicestack.net/img/external-tools-bundler.png)
<commit_msg>More information about the key value format for options<commit_after># Bundler

Bundler is a fast, command-line tool (easily integrated into existing IDEs, inc VS.NET) that statically **compiles**, **minifies** and **combines** your websites **less**, **sass**, **css**, **coffeescript** and **js** files.

  - All bundling is done at **compile time** with a build-step so no dependencies needed at runtime. 
  - Can be used with any website project (ie. not only .NET). Includes a **windows** node.exe although all scripts work cross-platform.
  - Includes a single C# **MvcBundler.cs** class with extension methods to seamlessly integrate it with any **ASP.NET MVC** website.
  - Runs outside the context of your ASP.NET MVC website so client scripts can be re-compiled **without restarting** your C# project.
  - Uses a self-contained **node.exe** for all compilation & minification - designed for maximum runtime and compile time performance.
  - Doesn't use any compiled dlls or .exe's (excl node.exe) and includes source code for everything so can easily be read and extended.

## Extremely fast at both Build and Runtime
Bundler is extremely fast - uses Googles leading V8 JavaScript engine (inside node.exe). All build scripts use only *pure JavaScript* implementations (uglifyjs, coffee-script, clean-css, etc) allowing all compilation and minification to run in a single process. 

#### Async / Non-Blocking
The packager is completely **async and non-blocking** - allowing the processing inside each bundle to happen in parallel. 

#### No Runtime overhead
Designed for maximum runtime performance since no compilation/minification happens at runtime. 
Even the generated HTML output is cached in memory (in production mode) - so has effectively no runtime overhead.

## How it works

You define css or js **bundles** (in plain text) that specifies the list of files you wish to bundle together. Running **bundler.cmd** (either as a short-cut key or post-build script) will scan through your **/Content** folder finding all defined **.js.bundle** and **.css.bundle** definition files which it goes through, only compiling and minifying new or modified files.

## Install

To run you just need a copy of **/bundler** folder in your website host directory. This can be done by cloning this repo or installing via NuGet:

[![Install-Pacakage ServiceStack.Host.Mvc](http://www.servicestack.net/img/nuget-bundler.png)](https://nuget.org/packages/Bundler)

*Once installed you can optionally exclude the '/bundler' or '/bundler/node_modules' folders from your VS.NET project since they contain a lot of files (not required to be referenced).*

By default bundler looks at **/Content** and **/Scripts** project folders - this can be changed by editing [/bundler/bundler.cmd](https://github.com/ServiceStack/Bundler/blob/master/NuGet/content/bundler/bundler.cmd):

    node bundler.js ../Content ../Scripts

Now you can define .bundles in any of the above folders. For illustration an example **app.js.bundle** and **app.css.bundle** text files are defined below:

**/Scripts/app.js.bundle**

	js/underscore.js
	js/backbone.js
	js/includes.js
	js/functions.coffee
	js/base.coffee
	bootstrap.js

**/Content/app.css.bundle**
	
	css/reset.css
	css/variables.less
	css/styles.less
	css/sassy.sass
	default.css

Now everytime you run **/bundler/bundler.cmd** it will scan these files, compiling and minifying any new or changed files. 

**Bundle file options**

Options can be specified to alter how your files are processed.  Options must be specified on the first line of the bundle file and the line must start with `#options `.  Options are comma delimited and each option is a key/value pair separated by a colon.  You can omit the value for boolean options and options specified without a value are set to true.

    #options nobundle
    css/reset.css
    css/variables.less
    default.css

The currently available options are:

1. **nobundle**: compiles and minifies all files listed, however it does not bundle them into a single file.  This allows you to compile and minify your standalone files without bundling them into another file.

Tip: For greater productivity integrate it with VS.NET by assiging a keyboard short-cut to **bundler.cmd** or run it as a post-build script so it's easily re-run it when your files have changed.

#### Create an External Tool inside VS.NET:

Allows you to run **Alt T + B** (or assign your own short-cut) to re-compile and minify your changed assets without re-building your project:

![Add External Tool in VS.NET](http://www.servicestack.net/img/external-tools-bundler.png)

{'fraction_non_alphanumeric': 0.08952740181939206, 'fraction_numerical': 0.00044375416019525185, 'mean_word_length': 4.220034742327736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4565496', 'n_tokens_mistral': 2526, 'n_tokens_neox': 2410, 'n_words': 1179}