Quantcast
Channel: Bundle Transformer - a modular extension for ASP.NET Web Optimization Framework
Viewing all 2358 articles
Browse latest View live

New Post: Undocumented dependancy on IE9

$
0
0
Bundle transformer uses the available javascript engine to do it's less compilation. The JS engine is supplied by version of IE installed on the server.

We have noticed that if IE8 is installed with it's older Javascript engine (rather than IE9's newer Chakra engine) we get out of memory errors when trying to use Bootstrap 3.0 less files. It appears to having issues with the built in functions spin, darken and lighten.

Has anyone else encountered this?

We are not in a position to upgrade our production servers to IE9.

New Post: Using with CssRewriteUrlTransform

$
0
0
You do not need CssRewriteUrlTransform.

Bundle Transformer itself resolves the relative paths in the CSS-files.

Created Unassigned: Typescript: exporting a class results in "Object reference not set to an instance of an object' [54]

$
0
0
First of all, thank you for all the hard work you've put into this library. You've made it possible for us to use MVC optimization to compile Bootstrap 3.0.

We're also interested in starting to use TypeScript. In one of my initial tests to get a feel for the language, however, I stumbled upon a frustrating error when trying to create exported classes.

It seems that when a class is exported using the 'export' keyword, the translation fails in the InnerTranslate() function of the TypeScriptTranslator.

To demonstrate the problem, I created a small project and [made it available](https://bitbucket.org/Dvde/typescripterror). Could you find the time to find out what is going wrong?

Commented Unassigned: Typescript: exporting a class results in "Object reference not set to an instance of an object' [54]

$
0
0
First of all, thank you for all the hard work you've put into this library. You've made it possible for us to use MVC optimization to compile Bootstrap 3.0.

We're also interested in starting to use TypeScript. In one of my initial tests to get a feel for the language, however, I stumbled upon a frustrating error when trying to create exported classes.

It seems that when a class is exported using the 'export' keyword, the translation fails in the InnerTranslate() function of the TypeScriptTranslator.

To demonstrate the problem, I created a small project and [made it available](https://bitbucket.org/Dvde/typescripterror). Could you find the time to find out what is going wrong?

Comments: The actual code contains this: ``` export class Example { }; ``` If I change it to this, it works again: ``` module MyModule { export class Example { }; } ``` I don't know if it's relevant. I also don't know if the former is actually valid TypeScript or not.

Commented Unassigned: Typescript: exporting a class results in "Object reference not set to an instance of an object' [54]

$
0
0
First of all, thank you for all the hard work you've put into this library. You've made it possible for us to use MVC optimization to compile Bootstrap 3.0.

We're also interested in starting to use TypeScript. In one of my initial tests to get a feel for the language, however, I stumbled upon a frustrating error when trying to create exported classes.

It seems that when a class is exported using the 'export' keyword, the translation fails in the InnerTranslate() function of the TypeScriptTranslator.

To demonstrate the problem, I created a small project and [made it available](https://bitbucket.org/Dvde/typescripterror). Could you find the time to find out what is going wrong?

Comments: Hello, DaveVdE! Here the problem is not in the Bundle Transformer. This code does not work in the command-line version TypeScript: ``` error TS5037: Cannot compile external modules unless the '--module' flag is provided. ``` A class can only export from the module: ``` module MyModule { export class Example { } } ``` I know that your code works in http://www.typescriptlang.org/Playground/, but Bundle Transformer does not support external modules (CommonJS and AMD). Support for this possibility difficult to implement due to the specificity of the loading of external modules. I recommend when learning to use the command-line version of the TypeScript. Also recommend you try the Web Essentials (http://vswebessentials.com/).

Commented Unassigned: Typescript: exporting a class results in "Object reference not set to an instance of an object' [54]

$
0
0
First of all, thank you for all the hard work you've put into this library. You've made it possible for us to use MVC optimization to compile Bootstrap 3.0.

We're also interested in starting to use TypeScript. In one of my initial tests to get a feel for the language, however, I stumbled upon a frustrating error when trying to create exported classes.

It seems that when a class is exported using the 'export' keyword, the translation fails in the InnerTranslate() function of the TypeScriptTranslator.

To demonstrate the problem, I created a small project and [made it available](https://bitbucket.org/Dvde/typescripterror). Could you find the time to find out what is going wrong?

Comments: In the next release I will add this information to the documentation.

Created Unassigned: Strict-mode does not allow assignment to undefined variables [55]

$
0
0
Столкнулся с ошибкой минимизации библиотеки qTip2 с помощью Microsoft Ajax JS-minifier:

Во время минимизации JS-кода, считанного из файла "/Scripts/jquery.qtip.js", с помощью Microsoft Ajax JS-minifier произошла синтаксическая ошибка!
Смотрите более подробную информацию об ошибке:

Сообщение об ошибке: Strict-mode does not allow assignment to undefined variables: i
Код ошибки: JS1300
Серьезность: 0
Подкатегория: run-time
Файл: /Scripts/jquery.qtip.js
Начальная строка: 3169
Начальный символ: 21
Конечная строка: 3169
Конечный символ: 22

В этом месте вот такой вот код:
```
for(result = [], i = -1, len = points.numberOfItems || points.length; ++i < len;) {
next = points.getItem ? points.getItem(i) : points[i];
result.push.apply(result, PLUGINS.svg.toPixel(elem, next.x, next.y));
}
```

Понимаю, что надо разработчиков просить исправить проблему в этом, и еще в куче других мест, но, почитал про Strict-mode и решил его отключить. Добавил в секцию bundleTransformer такой код:
```
<microsoftAjax>
<js strictMode="false"/>
</microsoftAjax>
```
Но, ничего не поменялось, ошибка недает запустить проект. Если пока оставить разработчиков qTip2 в покое, то хотел бы понять, что я не так делаю

Commented Unassigned: Strict-mode does not allow assignment to undefined variables [55]

$
0
0
Столкнулся с ошибкой минимизации библиотеки qTip2 с помощью Microsoft Ajax JS-minifier:

Во время минимизации JS-кода, считанного из файла "/Scripts/jquery.qtip.js", с помощью Microsoft Ajax JS-minifier произошла синтаксическая ошибка!
Смотрите более подробную информацию об ошибке:

Сообщение об ошибке: Strict-mode does not allow assignment to undefined variables: i
Код ошибки: JS1300
Серьезность: 0
Подкатегория: run-time
Файл: /Scripts/jquery.qtip.js
Начальная строка: 3169
Начальный символ: 21
Конечная строка: 3169
Конечный символ: 22

В этом месте вот такой вот код:
```
for(result = [], i = -1, len = points.numberOfItems || points.length; ++i < len;) {
next = points.getItem ? points.getItem(i) : points[i];
result.push.apply(result, PLUGINS.svg.toPixel(elem, next.x, next.y));
}
```

Понимаю, что надо разработчиков просить исправить проблему в этом, и еще в куче других мест, но, почитал про Strict-mode и решил его отключить. Добавил в секцию bundleTransformer такой код:
```
<microsoftAjax>
<js strictMode="false"/>
</microsoftAjax>
```
Но, ничего не поменялось, ошибка недает запустить проект. Если пока оставить разработчиков qTip2 в покое, то хотел бы понять, что я не так делаю
Comments: Эта опция просто добавляет в начале кода следующую строку: ``` "use strict"; ``` Прежде чем писать разработчикам Microsoft Ajax Minifier рекомендую сначала проверить код с помощью [JSHint](http://www.jshint.com). И огромная просьба больше не заводить баги, если они напрямую не относятся к Bundle Transformer, а то это сильно подрывает репутацию проекта.

Closed Unassigned: Strict-mode does not allow assignment to undefined variables [55]

$
0
0
Столкнулся с ошибкой минимизации библиотеки qTip2 с помощью Microsoft Ajax JS-minifier:

Во время минимизации JS-кода, считанного из файла "/Scripts/jquery.qtip.js", с помощью Microsoft Ajax JS-minifier произошла синтаксическая ошибка!
Смотрите более подробную информацию об ошибке:

Сообщение об ошибке: Strict-mode does not allow assignment to undefined variables: i
Код ошибки: JS1300
Серьезность: 0
Подкатегория: run-time
Файл: /Scripts/jquery.qtip.js
Начальная строка: 3169
Начальный символ: 21
Конечная строка: 3169
Конечный символ: 22

В этом месте вот такой вот код:
```
for(result = [], i = -1, len = points.numberOfItems || points.length; ++i < len;) {
next = points.getItem ? points.getItem(i) : points[i];
result.push.apply(result, PLUGINS.svg.toPixel(elem, next.x, next.y));
}
```

Понимаю, что надо разработчиков просить исправить проблему в этом, и еще в куче других мест, но, почитал про Strict-mode и решил его отключить. Добавил в секцию bundleTransformer такой код:
```
<microsoftAjax>
<js strictMode="false"/>
</microsoftAjax>
```
Но, ничего не поменялось, ошибка недает запустить проект. Если пока оставить разработчиков qTip2 в покое, то хотел бы понять, что я не так делаю

Commented Unassigned: Strict-mode does not allow assignment to undefined variables [55]

$
0
0
Столкнулся с ошибкой минимизации библиотеки qTip2 с помощью Microsoft Ajax JS-minifier:

Во время минимизации JS-кода, считанного из файла "/Scripts/jquery.qtip.js", с помощью Microsoft Ajax JS-minifier произошла синтаксическая ошибка!
Смотрите более подробную информацию об ошибке:

Сообщение об ошибке: Strict-mode does not allow assignment to undefined variables: i
Код ошибки: JS1300
Серьезность: 0
Подкатегория: run-time
Файл: /Scripts/jquery.qtip.js
Начальная строка: 3169
Начальный символ: 21
Конечная строка: 3169
Конечный символ: 22

В этом месте вот такой вот код:
```
for(result = [], i = -1, len = points.numberOfItems || points.length; ++i < len;) {
next = points.getItem ? points.getItem(i) : points[i];
result.push.apply(result, PLUGINS.svg.toPixel(elem, next.x, next.y));
}
```

Понимаю, что надо разработчиков просить исправить проблему в этом, и еще в куче других мест, но, почитал про Strict-mode и решил его отключить. Добавил в секцию bundleTransformer такой код:
```
<microsoftAjax>
<js strictMode="false"/>
</microsoftAjax>
```
Но, ничего не поменялось, ошибка недает запустить проект. Если пока оставить разработчиков qTip2 в покое, то хотел бы понять, что я не так делаю
Comments: На тот момент, я не мог определить достоверно, где источник ошибки, так как было подозрение, что <js strictMode="false"/> не выполняет требуемых действий, а он то относится к BundleTransformer непосредственно. А про строгий режим, я даже и не слышал раньше. Естественно, я ни коим образом не желал подрыва репутации ни проекту, ни разработчику, а наоборот, Ваши ответы и Ваша помощь должны повышать репутацию. Уверен, что другие пользователи так же высоко это ценят, как и я. Если это не так - простите уж. В дискуссии можно безболезненно для проекта задавать такие вопросы? По сути, <js strictMode="false"/> и не должен ничего делать, так как нет команды отключения строгого режима в спецификации, значит, к BundleTransformer действительно нет никаких вопросов. JSHint находит столько ошибок, что до этой даже не доходит. Интересно, почему другие минимизаторы легко обрабатывают эту библиотеку... Ну это уже риторический вопрос... Спасибо.

Commented Unassigned: Strict-mode does not allow assignment to undefined variables [55]

$
0
0
Столкнулся с ошибкой минимизации библиотеки qTip2 с помощью Microsoft Ajax JS-minifier:

Во время минимизации JS-кода, считанного из файла "/Scripts/jquery.qtip.js", с помощью Microsoft Ajax JS-minifier произошла синтаксическая ошибка!
Смотрите более подробную информацию об ошибке:

Сообщение об ошибке: Strict-mode does not allow assignment to undefined variables: i
Код ошибки: JS1300
Серьезность: 0
Подкатегория: run-time
Файл: /Scripts/jquery.qtip.js
Начальная строка: 3169
Начальный символ: 21
Конечная строка: 3169
Конечный символ: 22

В этом месте вот такой вот код:
```
for(result = [], i = -1, len = points.numberOfItems || points.length; ++i < len;) {
next = points.getItem ? points.getItem(i) : points[i];
result.push.apply(result, PLUGINS.svg.toPixel(elem, next.x, next.y));
}
```

Понимаю, что надо разработчиков просить исправить проблему в этом, и еще в куче других мест, но, почитал про Strict-mode и решил его отключить. Добавил в секцию bundleTransformer такой код:
```
<microsoftAjax>
<js strictMode="false"/>
</microsoftAjax>
```
Но, ничего не поменялось, ошибка недает запустить проект. Если пока оставить разработчиков qTip2 в покое, то хотел бы понять, что я не так делаю
Comments: В сообщении об ошибке написано, что ошибка синтаксическая, а значит эта ошибка произошла в минимизаторе, т.е. в Microsoft Ajax Minifier (BundleTransformer.MicrosoftAjax – это просто набор адаптеров). Еще раз повторю свою любимую фразу: «Не каждый файл можно сжать с помощью минимизатора.» Мне кажется, что ошибка заключается в том, что переменная i объявлена без директивы var. Если Вы еще не читали книгу Дугласа Крокфорда «JavaScript: The Good Parts», то настоятельно рекомендую ее прочитать, т.к. там разбираются некоторые тонкости языка, которые могут приводить к таким непонятным ошибкам. Краткую выжимку из Крокфорда можно посмотреть в видео-докладе Андрея Кулешова [«JavaScript: хороший тон клиентской разработки»](http://getdev.net/Event/javascript-good-form). По поводу багтрекера: лучше конечно о таких сомнительных ошибках писать в дискуссии, потому что в данный момент багтрекер просто забит псевдо-багами, которые вызваны непониманием синтаксиса LESS. У дискуссий есть лишь один минус – оповещения о них приходят ко мне только раз в день.

New Post: .less handler failing with stack overflow?

$
0
0
That may not be a realistic expectation for KendallB, it certainly is not for my team.

Would you consider switching your JavaScript depenancy to Noeis.Javascript? This is the Google V8 JavaScript engine in a .Net wrapper. it is available here:

https://javascriptdotnet.codeplex.com/

A member of my team has already altered the BundleTransformer locally to use Noeis.Javascript, and it is working fine.

Updated Wiki: Bundle Transformer 1.7.27

$
0
0

Bundle Transformer 1.7.27

Bundle Transformer logo

Before you read

Before you read the documentation for Bundle Transformer, i recommend to read chapter“Bundling and Minification” of the ASP.NET MVC 4 tutorial and Howard Dierking's article «New Web Optimization Pre-Release Package on NuGet». Also recommend you read the Rick Anderson's posts about using of Microsoft ASP.NET Web Optimization Framework with Web Forms and Web Pages.

Bundle Transformer does not minify HTML markup, embedded/inline styles and scripts. For these purposes it is recommended to useWebMarkupMin.

Examples of usage

Recommend to move the code, that is responsible for the registration of assets, from theGlobal.asax file in the BundleConfig.cs file and place this file in the App_Start directory. In the Global.asax file you need to leave only the code calling a method of classBundleConfig:

using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace BundleTransformer.Example.Mvc
{
   publicclass MvcApplication : System.Web.HttpApplication
   {
      protectedvoid Application_Start()
      {
         AreaRegistration.RegisterAllAreas();

         FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
         RouteConfig.RegisterRoutes(RouteTable.Routes);
         BundleConfig.RegisterBundles(BundleTable.Bundles);
      }
   }
}

Here an example of registration of assets and configuration of their processing with the help ofCssTransformer and JsTransformer in the BundleConfig.cs file:

namespace BundleTransformer.Example.Mvc
{
   using System.Web.Optimization;

   using Core.Builders;using Core.Orderers;using Core.Transformers;publicclass BundleConfig
   {
      publicstaticvoid RegisterBundles(BundleCollection bundles)
      {
         bundles.UseCdn = true;

         var nullBuilder = new NullBuilder();var cssTransformer = new CssTransformer();var jsTransformer = new JsTransformer();var nullOrderer = new NullOrderer();

         var commonStylesBundle = new Bundle("~/Bundles/CommonStyles");
         commonStylesBundle.Include(
            "~/Content/Fonts.css",
            "~/Content/Site.css",
            "~/Content/BundleTransformer.css",
            "~/AlternativeContent/css/TestCssComponentsPaths.css",
            "~/Content/themes/base/jquery.ui.core.css",
            "~/Content/themes/base/jquery.ui.theme.css",
            "~/Content/themes/base/jquery.ui.resizable.css",
            "~/Content/themes/base/jquery.ui.button.css",
            "~/Content/themes/base/jquery.ui.dialog.css",
            "~/Content/TestTranslators.css",
            "~/Content/less/TestLess.less",
            "~/Content/sass/TestSass.sass",
            "~/Content/scss/TestScss.scss");
         commonStylesBundle.Builder = nullBuilder;
         commonStylesBundle.Transforms.Add(cssTransformer);
         commonStylesBundle.Orderer = nullOrderer;

         bundles.Add(commonStylesBundle);

         var modernizrBundle = new Bundle("~/Bundles/Modernizr");
         modernizrBundle.Include("~/Scripts/modernizr-2.*");
         modernizrBundle.Builder = nullBuilder;
         modernizrBundle.Transforms.Add(jsTransformer);
         modernizrBundle.Orderer = nullOrderer;

         bundles.Add(modernizrBundle);

         var jQueryBundle = new Bundle("~/Bundles/Jquery", 
            "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js");
         jQueryBundle.Include("~/Scripts/jquery-{version}.js");
         jQueryBundle.Builder = nullBuilder;
         jQueryBundle.Transforms.Add(jsTransformer);
         jQueryBundle.Orderer = nullOrderer;
         jQueryBundle.CdnFallbackExpression = "window.jquery";

         bundles.Add(jQueryBundle);

         var commonScriptsBundle = new Bundle("~/Bundles/CommonScripts");
         commonScriptsBundle.Include("~/Scripts/MicrosoftAjax.js",
            "~/Scripts/jquery-ui-{version}.js",
            "~/Scripts/jquery.validate.js",
            "~/Scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.unobtrusive-ajax.js",
            "~/Scripts/knockout-2.*",
            "~/Scripts/coffee/TestCoffeeScript.coffee",
            "~/Scripts/coffee/TestLiterateCoffeeScript.litcoffee",
            "~/Scripts/coffee/TestCoffeeScriptMarkdown.coffee.md",
            "~/Scripts/ts/TranslatorBadge.ts",
            "~/Scripts/ts/ColoredTranslatorBadge.ts",
            "~/Scripts/ts/TestTypeScript.ts");
         commonStylesBundle.Builder = nullBuilder;
         commonScriptsBundle.Transforms.Add(jsTransformer);
         commonScriptsBundle.Orderer = nullOrderer;

         bundles.Add(commonScriptsBundle);
         …
      }
   }
}

NullBuilder class is responsible for prevention of early applying of the item transformations and combining of code.CssTransformer and JsTransformer classes produce processing of stylesheets and scripts. NullOrderer class disables the built-in sorting mechanism and save assets sorted in the order they are declared.

Bundle Transformer is not recommended to use together with the StyleBundle and ScriptBundle classes, because these classes already contain transformations (instances of the built-in minifier-transformations:CssMinify and JsMinify). If you are in this situation plug the Bundle Transformer minifiers-modules (for example, BundleTransformer.MicrosoftAjax or BundleTransformer.Yui), then it will lead to a double minification of code. In addition, minifier-modules of the Bundle Transformer do not produce the re-minification of code of pre-minified assets (for example, files with the extension*.min.js and *.min.css), that speeds up the process of optimization.

You also need to understand that when you plug instances of CssTransformer and JsTransformer classes, then you plug in a set of transformations (choice between debug and pre-minified versions of files, translation code from the intermediate languages, runtime code minification, transformation of relative paths to absolute (only for CSS-code) and code combining). A set of transformations depends on what the modules of Bundle Transformer you have installed and settings you have specified in theWeb.config file.

Also note, that CssMinify and JsMinify was created on the basis of the Microsoft Ajax Minifier. Therefore, as a their replacement you can use minifier-module the BundleTransformer.MicrosoftAjax, which supports a newer version of the Microsoft Ajax Minifier algorithm and allows you to make a more fine-tuning of this algorithm.

Above code can be a bit shorter, if you will use the CustomStyleBundle and CustomScriptBundle classes:

namespace BundleTransformer.Example.Mvc
{
   using System.Web.Optimization;

   using Core.Builders;
   using Core.Bundles;using Core.Orderers;
   using Core.Transformers;

   publicclass BundleConfig
   {
      publicstaticvoid RegisterBundles(BundleCollection bundles)
      {
         bundles.UseCdn = true;

         var nullBuilder = new NullBuilder();
         var nullOrderer = new NullOrderer();

         var commonStylesBundle = newCustomStyleBundle("~/Bundles/CommonStyles");
         commonStylesBundle.Include(
            "~/Content/Fonts.css",
            "~/Content/Site.css",
            "~/Content/BundleTransformer.css",
            "~/AlternativeContent/css/TestCssComponentsPaths.css",
            "~/Content/themes/base/jquery.ui.core.css",
            "~/Content/themes/base/jquery.ui.theme.css",
            "~/Content/themes/base/jquery.ui.resizable.css",
            "~/Content/themes/base/jquery.ui.button.css",
            "~/Content/themes/base/jquery.ui.dialog.css",
            "~/Content/TestTranslators.css",
            "~/Content/less/TestLess.less",
            "~/Content/sass/TestSass.sass",
            "~/Content/scss/TestScss.scss");
         commonStylesBundle.Orderer = nullOrderer;

         bundles.Add(commonStylesBundle);

         var modernizrBundle = newCustomScriptBundle("~/Bundles/Modernizr");
         modernizrBundle.Include("~/Scripts/modernizr-2.*");
         modernizrBundle.Orderer = nullOrderer;

         bundles.Add(modernizrBundle);

         var jQueryBundle = newCustomScriptBundle("~/Bundles/Jquery", 
            "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js");
         jQueryBundle.Include("~/Scripts/jquery-{version}.js");
         jQueryBundle.Orderer = nullOrderer;
         jQueryBundle.CdnFallbackExpression = "window.jquery";

         bundles.Add(jQueryBundle);

         var commonScriptsBundle = newCustomScriptBundle("~/Bundles/CommonScripts");
         commonScriptsBundle.Include("~/Scripts/MicrosoftAjax.js",
            "~/Scripts/jquery-ui-{version}.js",
            "~/Scripts/jquery.validate.js",
            "~/Scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.unobtrusive-ajax.js",
            "~/Scripts/knockout-2.*",
            "~/Scripts/coffee/TestCoffeeScript.coffee",
            "~/Scripts/coffee/TestLiterateCoffeeScript.litcoffee",
            "~/Scripts/coffee/TestCoffeeScriptMarkdown.coffee.md",
            "~/Scripts/ts/TranslatorBadge.ts",
            "~/Scripts/ts/ColoredTranslatorBadge.ts",
            "~/Scripts/ts/TestTypeScript.ts");
         commonScriptsBundle.Orderer = nullOrderer;

         bundles.Add(commonScriptsBundle);
         …
      }
   }
}

CustomStyleBundle and CustomScriptBundleсlasses are analogues of the StyleBundle and ScriptBundle classes, oriented to work with the Bundle Transformer.CustomStyleBundle class uses CssTransformer as transformation by default and NullBuilder as builder by default, and CustomScriptBundle class uses JsTransformer as transformation by default andNullBuilder as builder by default.

Example of _Layout.cshtml:

<!DOCTYPEhtml><htmllang="en"><head><metacharset="utf-8"/><title>@ViewBag.Title - Bundle Transformer Example MVC Application</title><linkhref="~/favicon.ico"rel="shortcut icon"type="image/x-icon"/><metaname="viewport"content="width=device-width"/>
      @Styles.Render("~/Bundles/CommonStyles")
      @Scripts.Render("~/Bundles/Modernizr")
   </head><body>
      ...
      @Scripts.Render("~/Bundles/Jquery")
      @Scripts.Render("~/Bundles/CommonScripts")
      @RenderSection("scripts", required: false)
   </body></html>

When adding assets from directory, you can specify patterns for exclusion of unnecessary files (ignorePatterns parameter):

var jqueryUiStylesDirectoryBundle = new Bundle("~/Bundles/JqueryUiStylesDirectory");
jqueryUiStylesDirectoryBundle.Builder = nullBuilder;
jqueryUiStylesDirectoryBundle.IncludeDirectory("~/Content/themes/base/", "*.css");
jqueryUiStylesDirectoryBundle.Transforms.Add(new CssTransformer(
   new[] { "*.all.css", "jquery.ui.base.css" }));

bundles.Add(jqueryUiStylesDirectoryBundle);

var scriptsDirectoryBundle = new Bundle("~/Bundles/ScriptsDirectory");
scriptsDirectoryBundle.Builder = nullBuilder;
scriptsDirectoryBundle.IncludeDirectory("~/Scripts/", "*.js", true);
scriptsDirectoryBundle.Transforms.Add(new JsTransformer(
   new[] { "*.all.js", "references.js" }));

bundles.Add(scriptsDirectoryBundle);

Configuration settings

Starting with version 1.2.1 Beta from the Web.config file has been removed settings of Bundle Transformer, which were default settings. Current settings of Bundle Transformer equivalent to following version of theWeb.config file:

<?xmlversion="1.0"encoding="utf-8"?><configuration><configSections><!-- Declaration of Bundle Transformer configuration section group --><sectionGroupname="bundleTransformer"><sectionname="core"type="BundleTransformer.Core.Configuration.CoreSettings, BundleTransformer.Core"/><sectionname="less"type="BundleTransformer.Less.Configuration.LessSettings, BundleTransformer.Less"/><sectionname="sassAndScss"type="BundleTransformer.SassAndScss.Configuration.SassAndScssSettings, BundleTransformer.SassAndScss"/><sectionname="typeScript"type="BundleTransformer.TypeScript.Configuration.TypeScriptSettings, BundleTransformer.TypeScript"/><sectionname="coffeeScript"type="BundleTransformer.CoffeeScript.Configuration.CoffeeScriptSettings, BundleTransformer.CoffeeScript"/><sectionname="microsoftAjax"type="BundleTransformer.MicrosoftAjax.Configuration.MicrosoftAjaxSettings, BundleTransformer.MicrosoftAjax"/><sectionname="yui"type="BundleTransformer.Yui.Configuration.YuiSettings, BundleTransformer.Yui"/><sectionname="closure"type="BundleTransformer.Closure.Configuration.ClosureSettings, BundleTransformer.Closure"/><sectionname="uglify"type="BundleTransformer.UglifyJs.Configuration.UglifySettings, BundleTransformer.UglifyJs"/><sectionname="packer"type="BundleTransformer.Packer.Configuration.PackerSettings, BundleTransformer.Packer"/><sectionname="csso"type="BundleTransformer.Csso.Configuration.CssoSettings, BundleTransformer.Csso"/></sectionGroup><!-- /Declaration of Bundle Transformer configuration section group --></configSections><system.web><httpHandlers><!-- Declaration of Bundle Transformer HTTP-handlers --><addpath="*.less"verb="GET"type="BundleTransformer.Less.HttpHandlers.LessAssetHandler, BundleTransformer.Less"/><addpath="*.sass"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"/><addpath="*.scss"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"/><addpath="*.coffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.litcoffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.coffee.md"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.ts"verb="GET"type="BundleTransformer.TypeScript.HttpHandlers.TypeScriptAssetHandler, BundleTransformer.TypeScript"/><!-- /Declaration of Bundle Transformer HTTP-handlers --></httpHandlers></system.web><system.webServer><handlers><!-- Declaration of Bundle Transformer HTTP-handlers --><addname="LessAssetHandler"path="*.less"verb="GET"type="BundleTransformer.Less.HttpHandlers.LessAssetHandler, BundleTransformer.Less"resourceType="File" preCondition=""/><addname="SassAssetHandler"path="*.sass"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"resourceType="File" preCondition=""/><addname="ScssAssetHandler"path="*.scss"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"resourceType="File" preCondition=""/><addname="CoffeeScriptAssetHandler"path="*.coffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="LiterateCoffeeScriptAssetHandler"path="*.litcoffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="CoffeeScriptMarkdownAssetHandler"path="*.coffee.md"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="TypeScriptAssetHandler"path="*.ts"verb="GET"type="BundleTransformer.TypeScript.HttpHandlers.TypeScriptAssetHandler, BundleTransformer.TypeScript"resourceType="File" preCondition=""/><!-- /Declaration of Bundle Transformer HTTP-handlers --></handlers></system.webServer><!-- Bundle Transformer configuration settings --><bundleTransformerxmlns="http://tempuri.org/BundleTransformer.Configuration.xsd"><coreenableTracing="false"jsFilesWithMicrosoftStyleExtensions="MicrosoftAjax.js,MicrosoftMvcAjax.js, MicrosoftMvcValidation.js,knockout-$version$.js"useEnableOptimizationsProperty="true"><cssdefaultMinifier="NullMinifier"usePreMinifiedFiles="true"disableNativeCssRelativePathTransformation="false"><minifiers><addname="NullMinifier"type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core"/><addname="MicrosoftAjaxCssMinifier"type="BundleTransformer.MicrosoftAjax.Minifiers.MicrosoftAjaxCssMinifier, BundleTransformer.MicrosoftAjax"/><addname="YuiCssMinifier"type="BundleTransformer.Yui.Minifiers.YuiCssMinifier, BundleTransformer.Yui"/><addname="KryzhanovskyCssMinifier"type="BundleTransformer.Csso.Minifiers.KryzhanovskyCssMinifier, BundleTransformer.Csso"/><addname="WgCssMinifier"type="BundleTransformer.WG.Minifiers.WgCssMinifier, BundleTransformer.WG"/></minifiers><translators><addname="NullTranslator"type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core"enabled="false"/><addname="LessTranslator"type="BundleTransformer.Less.Translators.LessTranslator, BundleTransformer.Less"enabled="true"/><addname="SassAndScssTranslator"type="BundleTransformer.SassAndScss.Translators.SassAndScssTranslator, BundleTransformer.SassAndScss"enabled="true"/></translators></css><jsdefaultMinifier="NullMinifier"usePreMinifiedFiles="true"><minifiers><addname="NullMinifier"type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core"/><addname="MicrosoftAjaxJsMinifier"type="BundleTransformer.MicrosoftAjax.Minifiers.MicrosoftAjaxJsMinifier, BundleTransformer.MicrosoftAjax"/><addname="YuiJsMinifier"type="BundleTransformer.Yui.Minifiers.YuiJsMinifier, BundleTransformer.Yui"/><addname="ClosureRemoteJsMinifier"type="BundleTransformer.Closure.Minifiers.ClosureRemoteJsMinifier, BundleTransformer.Closure"/><addname="ClosureLocalJsMinifier"type="BundleTransformer.Closure.Minifiers.ClosureLocalJsMinifier, BundleTransformer.Closure"/><addname="CrockfordJsMinifier"type="BundleTransformer.JsMin.Minifiers.CrockfordJsMinifier, BundleTransformer.JsMin"/><addname="UglifyJsMinifier"type="BundleTransformer.UglifyJs.Minifiers.UglifyJsMinifier, BundleTransformer.UglifyJs"/><addname="EdwardsJsMinifier"type="BundleTransformer.Packer.Minifiers.EdwardsJsMinifier, BundleTransformer.Packer"/></minifiers><translators><addname="NullTranslator"type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core"enabled="false"/><addname="CoffeeScriptTranslator"type="BundleTransformer.CoffeeScript.Translators.CoffeeScriptTranslator, BundleTransformer.CoffeeScript"enabled="true"/><addname="TypeScriptTranslator"type="BundleTransformer.TypeScript.Translators.TypeScriptTranslator, BundleTransformer.TypeScript"enabled="true"/></translators></js></core><lessuseNativeMinification="false"ieCompat="true"strictMath="false"strictUnits="false"dumpLineNumbers="None"/><sassAndScssuseNativeMinification="false"lineNumbers="false"traceSelectors="false"debugInfo="false"/><coffeeScriptbare="true"/><typeScriptuseDefaultLib="true"propagateEnumConstants="false"removeComments="false"allowAutomaticSemicolonInsertion="true"allowBool="false"noImplicitAny="false"codeGenTarget="EcmaScript3"/><microsoftAjax><cssallowEmbeddedAspNetBlocks="false"blocksStartOnSameLine="NewLine"ignoreAllErrors="false"ignoreErrorList="" indentSize="4"lineBreakThreshold="2147482647"outputMode="SingleLine"preprocessorDefineList="" termSemicolons="false"colorNames="Strict"commentMode="Important"minifyExpressions="true"severity="0"/><jsallowEmbeddedAspNetBlocks="false"blocksStartOnSameLine="NewLine"ignoreAllErrors="false"ignoreErrorList="" indentSize="4"lineBreakThreshold="2147482647"outputMode="SingleLine"preprocessorDefineList="" termSemicolons="false"alwaysEscapeNonAscii="false"collapseToLiteral="true"constStatementsMozilla="false"debugLookupList="Debug,$Debug,WAssert,Msn.Debug,Web.Debug"errorIfNotInlineSafe="false"evalLiteralExpressions="true"evalTreatment="Ignore"ignoreConditionalCompilation="false"ignorePreprocessorDefines="false"inlineSafeStrings="true"knownGlobalNamesList="" localRenaming="CrunchAll"macSafariQuirks="true"manualRenamesProperties="true"noAutoRenameList="$super"preserveFunctionNames="false"preserveImportantComments="true"quoteObjectLiteralProperties="false"removeFunctionExpressionNames="true"removeUnneededCode="true"renamePairs="" reorderScopeDeclarations="true"strictMode="false"stripDebugStatements="true"severity="0"/></microsoftAjax><yui><csscompressionType="Standard"removeComments="true"lineBreakPosition="-1"/><jscompressionType="Standard"obfuscateJavascript="true"preserveAllSemicolons="false"disableOptimizations="false"ignoreEval="false"severity="0"lineBreakPosition="-1"encoding="UTF8"threadCulture="en-us"/></yui><closure><js><remoteclosureCompilerServiceApiUrl="http://closure-compiler.appspot.com/compile"compilationLevel="Simple"prettyPrint="false"excludeDefaultExterns="false"severity="0"/><localjavaVirtualMachinePath="" closureCompilerApplicationPath=""compilationLevel="Simple"prettyPrint="false"languageSpec="EcmaScript3"thirdParty="true"processJqueryPrimitives="false"processClosurePrimitives="false"severity="0"/></js></closure><uglify><jsscrewIe8="false"severity="0"><parsingstrict="false"/><compression compress="true" sequences="true" propertiesDotNotation="true"
          deadCode="true" dropDebugger="true" unsafe="false"
          conditionals="true" comparisons="true" evaluate="true"
          booleans="true" loops="true" unused="true"
          hoistFunctions="true" hoistVars="false" ifReturn="true"
          joinVars="true" cascade="true"
          globalDefinitions="" />
        <manglingmangle="true"except="" eval="false"sort="false"topLevel="false"/><codeGenerationbeautify="false"indentLevel="4"indentStart="0"quoteKeys="false"spaceColon="true"asciiOnly="false"inlineScript="false"width="80"maxLineLength="32000"ieProof="true"bracketize="false"semicolons="true"comments="false"preserveLine="false"/></js></uglify><packer><jsshrinkVariables="true"base62Encode="false"/></packer><csso><cssdisableRestructuring="false"/></csso></bundleTransformer><!-- /Bundle Transformer configuration settings --></configuration>

Also since version 1.2.1 Beta in the Web.config file for thebundleTransformer configuration section was implemented support for IntelliSense (implemented by using XML Schema, which is located in theBundleTransformer.Configuration.xsd file):

IntelliSense support when editing the  bundleTransformer configuration section in the Web.config file

Translators

Bundle Transformer: LESS and Bundle Transformer: LESS Lite

BundleTransformer.Less andBundleTransformer.LessLite contains translator-adapterLessTranslator (supports LESS version 1.4.2). This adapter makes translation of LESS-code to CSS-code. Also contains HTTP-handlerLessAssetHandler, which is responsible for text output of translated LESS-asset.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

Bundle Transformer: Sass and SCSS

BundleTransformer.SassAndScss contains translator-adapterSassAndScssTranslator (based on code of theSassAndCoffee.Ruby library version 2.0.2.0 withRobert Wintermoose's Update and supportsSass version 3.2.10). This adapter makes translation of Sass- and SCSS-code to CSS-code. Also contains HTTP-handlerSassAndScssAssetHandler, which is responsible for text output of translated Sass- or SCSS-asset.

Bundle Transformer: CoffeeScript

BundleTransformer.CoffeeScript contains translator-adapterCoffeeScriptTranslator (supports CoffeeScript version 1.6.3). This adapter makes translation of CoffeeScript-code to JS-code. Also contains HTTP-handlerCoffeeScriptAssetHandler, which is responsible for text output of translated CoffeeScript-asset.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

Bundle Transformer: TypeScript

BundleTransformer.TypeScript contains translator-adapterTypeScriptTranslator (supports TypeScript version 0.9.1.1). This adapter makes translation of TypeScript-code to JS-code. Also contains HTTP-handlerTypeScriptAssetHandler, which is responsible for text output of translated TypeScript-asset.

BundleTransformer.TypeScript does not support external modules (CommonJS and AMD modules).

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

When using the types declared in other files, you need add to code the references to these files by using the "reference" comments, as shown in the following example:

/// <reference path="jquery.d.ts" />/// <reference path="TranslatorBadge.ts" />/// <summary>/// Creates colored badge for translator/// </summary>
;class ColoredTranslatorBadge extends TranslatorBadge {
	public getTextColor(): string {
		/// <summary>/// Gets a text color of badge/// </summary>/// <returns type="String">/// Text color of badge/// </returns>returnthis.$linkElem.css("color"); 
	}

	public setTextColor(color: string): void {
		/// <summary>/// Sets a text color of badge/// </summary>/// <param name="color" type="String">/// Text color of badge/// </param>this.$linkElem.css("color", color);
	}

	public getBorderColor(): string {
		/// <summary>/// Gets a border color of badge/// </summary>/// <returns type="String">/// Border color of badge/// </returns>returnthis.$badgeElem.css("border-color");
	} 

	public setBorderColor(color: string) {
		/// <summary>/// Sets a border color of badge/// </summary>/// <param name="color" type="String">/// Border color of badge/// </param>this.$badgeElem.css("border-color", color);
	}
}

Minifiers

Bundle Transformer: Microsoft Ajax

BundleTransformer.MicrosoftAjax contains 2 minifier-adapters:MicrosoftAjaxCssMinifier (for minification of CSS-code) andMicrosoftAjaxJsMinifier (for minification of JS-code). These adapters perform minification using theMicrosoft Ajax Minifier.

To make MicrosoftAjaxCssMinifier is the default CSS-minifier andMicrosoftAjaxJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In defaultMinifier attribute of \configuration\bundleTransformer\core\css element must be set value equal toMicrosoftAjaxCssMinifier, and in same attribute of\configuration\bundleTransformer\core\js element -MicrosoftAjaxJsMinifier.

Bundle Transformer: YUI

BundleTransformer.Yui contains 2 minifier-adapters:YuiCssMinifier (for minification of CSS-code) andYuiJsMinifier (for minification of JS-code). These adapters perform minification using theYUI Compressor for .NET.

To make YuiCssMinifier is the default CSS-minifier andYuiJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In defaultMinifier attribute of \configuration\bundleTransformer\core\css element must be set value equal toYuiCssMinifier, and in same attribute of\configuration\bundleTransformer\core\js element -YuiJsMinifier.

Bundle Transformer: Closure

BundleTransformer.Closure contains 2 minifier-adapters for minification of JS-code:ClosureRemoteJsMinifier and ClosureLocalJsMinifier. ClosureRemoteJsMinifier is based on the Google Closure Compiler Service API and requires a permanent connection to Internet.ClosureLocalJsMinifier is based on the Google Closure Compiler Application and for their work requires latest version of filecompiler.jar.

To make ClosureRemoteJsMinifier orClosureLocalJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toClosureRemoteJsMinifier or ClosureLocalJsMinifier.

To start using ClosureLocalJsMinifier need to make the following preliminary work:

  1. On your computer must be installed Java 6 or higher. Latest version of Java can be downloaded at the following URL -http://www.java.com/download/.
  2. You need to download latest version of the Google Closure Compiler Application, which is located on the URL - http://closure-compiler.googlecode.com/files/compiler-latest.zip.
  3. Unzip the downloaded archive and copy the file compiler.jar in some directory on disk of your computer.
  4. In Web.config file find the configuration/bundleTransformer/closure/local element, then set the javaVirtualMachinePath attribute to a value equal to the path to executable file of the Java Virtual Machine (java.exe), and set theclosureCompilerApplicationPath attribute to a value equal to the path to JAR-file of the Google Closure Compiler Application (compiler.jar).

Bundle Transformer: JSMin

BundleTransformer.JsMin contains one minifier-adapter for minification of JS-code -CrockfordJsMinifier. CrockfordJsMinifier is based on the C# port of Douglas Crockford's JSMin (version of May 22 2007).

To make CrockfordJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toCrockfordJsMinifier.

Bundle Transformer: UglifyJS

BundleTransformer.UglifyJs contains one minifier-adapter for minification of JS-code -UglifyJsMinifier. UglifyJsMinifier is based on the Mihai Bazon's UglifyJS version 2.3.6.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

To make UglifyJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toUglifyJsMinifier.

Bundle Transformer: Packer

BundleTransformer.Packer contains one minifier-adapter for minification of JS-code -EdwardsJsMinifier. EdwardsJsMinifier is based on the Dean Edwards' Packer version 3.0.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

To make EdwardsJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toEdwardsJsMinifier.

Bundle Transformer: CSSO

BundleTransformer.Csso contains one minifier-adapter for minification of CSS-code -KryzhanovskyCssMinifier. KryzhanovskyCssMinifier is based on the Sergey Kryzhanovsky's CSSO (CSS Optimizer) version 1.3.7.

As a JS-engine is used the Noesis Javascript .NET. BundleTransformer.Csso in runtime itself switches to correct version of the Noesis Javascript .NET (assemblies for different platforms are located in theApp_Data/Noesis.Javascript directory). For correct working of the Noesis Javascript .NET require assembliesmsvcp100.dll and msvcr100.dll from the Microsoft Visual C++ 2010.

If in your system does not assemblies msvcp100.dll andmsvcr100.dll, then download and install the Microsoft Visual C++ 2010 Redistributable Package (x86, x64)

To make KryzhanovskyCssMinifier is the default CSS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\css element must be set value equal toKryzhanovskyCssMinifier.

Bundle Transformer: WebGrease

BundleTransformer.WG contains one minifier-adapter for minification of CSS-code -WgCssMinifier. WgCssMinifier is based on the WebGrease Semantic CSS-minifier version 1.3.0.

To make WgCssMinifier is the default CSS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\css element must be set value equal toWgCssMinifier.

New Post: .less handler failing with stack overflow?

$
0
0
You know that for Noesis Javascript.NET on the server you need to install the Microsoft Visual C++ 2010 Redistributable Package? In addition, this product is in Beta status.

One of my minifiers uses it - BundleTransformer.Csso. There are some problems mainly related with need to switch assemblies for different platforms (x86 and x64). If a sober look at things, then for the Noesis need a wrapper (switcher).

I am glad you managed to connect the Noesis to the BundleTransformer.Less. For this and created Open Source.

I just don't understand why are you making me claim? Bundle Transformer is an Open Source project (you can read the text of the license). And you behave like a disgruntled user of a commercial product. User Spamagnet writing offensive things.

In the next few months I can't solve your problem. Or install Internet Explorer 9, or use your assembly on the basis of Noesis.

Updated Wiki: Bundle Transformer 1.7.27

$
0
0

Bundle Transformer 1.7.27

Bundle Transformer logo

Before you read

Before you read the documentation for Bundle Transformer, i recommend to read chapter“Bundling and Minification” of the ASP.NET MVC 4 tutorial and Howard Dierking's article «New Web Optimization Pre-Release Package on NuGet». Also recommend you read the Rick Anderson's posts about using of Microsoft ASP.NET Web Optimization Framework with Web Forms and Web Pages.

Bundle Transformer does not minify HTML markup, embedded/inline styles and scripts. For these purposes it is recommended to useWebMarkupMin.

Examples of usage

Recommend to move the code, that is responsible for the registration of assets, from theGlobal.asax file in the BundleConfig.cs file and place this file in the App_Start directory. In the Global.asax file you need to leave only the code calling a method of classBundleConfig:

using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace BundleTransformer.Example.Mvc
{
   publicclass MvcApplication : System.Web.HttpApplication
   {
      protectedvoid Application_Start()
      {
         AreaRegistration.RegisterAllAreas();

         FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
         RouteConfig.RegisterRoutes(RouteTable.Routes);
         BundleConfig.RegisterBundles(BundleTable.Bundles);
      }
   }
}

Here an example of registration of assets and configuration of their processing with the help ofCssTransformer and JsTransformer in the BundleConfig.cs file:

namespace BundleTransformer.Example.Mvc
{
   using System.Web.Optimization;

   using Core.Builders;using Core.Orderers;using Core.Transformers;publicclass BundleConfig
   {
      publicstaticvoid RegisterBundles(BundleCollection bundles)
      {
         bundles.UseCdn = true;

         var nullBuilder = new NullBuilder();var cssTransformer = new CssTransformer();var jsTransformer = new JsTransformer();var nullOrderer = new NullOrderer();

         var commonStylesBundle = new Bundle("~/Bundles/CommonStyles");
         commonStylesBundle.Include(
            "~/Content/Fonts.css",
            "~/Content/Site.css",
            "~/Content/BundleTransformer.css",
            "~/AlternativeContent/css/TestCssComponentsPaths.css",
            "~/Content/themes/base/jquery.ui.core.css",
            "~/Content/themes/base/jquery.ui.theme.css",
            "~/Content/themes/base/jquery.ui.resizable.css",
            "~/Content/themes/base/jquery.ui.button.css",
            "~/Content/themes/base/jquery.ui.dialog.css",
            "~/Content/TestTranslators.css",
            "~/Content/less/TestLess.less",
            "~/Content/sass/TestSass.sass",
            "~/Content/scss/TestScss.scss");
         commonStylesBundle.Builder = nullBuilder;
         commonStylesBundle.Transforms.Add(cssTransformer);
         commonStylesBundle.Orderer = nullOrderer;

         bundles.Add(commonStylesBundle);

         var modernizrBundle = new Bundle("~/Bundles/Modernizr");
         modernizrBundle.Include("~/Scripts/modernizr-2.*");
         modernizrBundle.Builder = nullBuilder;
         modernizrBundle.Transforms.Add(jsTransformer);
         modernizrBundle.Orderer = nullOrderer;

         bundles.Add(modernizrBundle);

         var jQueryBundle = new Bundle("~/Bundles/Jquery", 
            "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js");
         jQueryBundle.Include("~/Scripts/jquery-{version}.js");
         jQueryBundle.Builder = nullBuilder;
         jQueryBundle.Transforms.Add(jsTransformer);
         jQueryBundle.Orderer = nullOrderer;
         jQueryBundle.CdnFallbackExpression = "window.jquery";

         bundles.Add(jQueryBundle);

         var commonScriptsBundle = new Bundle("~/Bundles/CommonScripts");
         commonScriptsBundle.Include("~/Scripts/MicrosoftAjax.js",
            "~/Scripts/jquery-ui-{version}.js",
            "~/Scripts/jquery.validate.js",
            "~/Scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.unobtrusive-ajax.js",
            "~/Scripts/knockout-2.*",
            "~/Scripts/coffee/TestCoffeeScript.coffee",
            "~/Scripts/coffee/TestLiterateCoffeeScript.litcoffee",
            "~/Scripts/coffee/TestCoffeeScriptMarkdown.coffee.md",
            "~/Scripts/ts/TranslatorBadge.ts",
            "~/Scripts/ts/ColoredTranslatorBadge.ts",
            "~/Scripts/ts/TestTypeScript.ts");
         commonStylesBundle.Builder = nullBuilder;
         commonScriptsBundle.Transforms.Add(jsTransformer);
         commonScriptsBundle.Orderer = nullOrderer;

         bundles.Add(commonScriptsBundle);
         …
      }
   }
}

NullBuilder class is responsible for prevention of early applying of the item transformations and combining of code.CssTransformer and JsTransformer classes produce processing of stylesheets and scripts. NullOrderer class disables the built-in sorting mechanism and save assets sorted in the order they are declared.

Bundle Transformer is not recommended to use together with the StyleBundle and ScriptBundle classes, because these classes already contain transformations (instances of the built-in minifier-transformations:CssMinify and JsMinify). If you are in this situation plug the Bundle Transformer minifiers-modules (for example, BundleTransformer.MicrosoftAjax or BundleTransformer.Yui), then it will lead to a double minification of code. In addition, minifier-modules of the Bundle Transformer do not produce the re-minification of code of pre-minified assets (for example, files with the extension*.min.js and *.min.css), that speeds up the process of optimization.

You also need to understand that when you plug instances of CssTransformer and JsTransformer classes, then you plug in a set of transformations (choice between debug and pre-minified versions of files, translation code from the intermediate languages, runtime code minification, transformation of relative paths to absolute (only for CSS-code) and code combining). A set of transformations depends on what the modules of Bundle Transformer you have installed and settings you have specified in theWeb.config file.

Also note, that CssMinify and JsMinify was created on the basis of the Microsoft Ajax Minifier. Therefore, as a their replacement you can use minifier-module the BundleTransformer.MicrosoftAjax, which supports a newer version of the Microsoft Ajax Minifier algorithm and allows you to make a more fine-tuning of this algorithm.

Above code can be a bit shorter, if you will use the CustomStyleBundle and CustomScriptBundle classes:

namespace BundleTransformer.Example.Mvc
{
   using System.Web.Optimization;

   using Core.Builders;
   using Core.Bundles;using Core.Orderers;
   using Core.Transformers;

   publicclass BundleConfig
   {
      publicstaticvoid RegisterBundles(BundleCollection bundles)
      {
         bundles.UseCdn = true;

         var nullBuilder = new NullBuilder();
         var nullOrderer = new NullOrderer();

         var commonStylesBundle = newCustomStyleBundle("~/Bundles/CommonStyles");
         commonStylesBundle.Include(
            "~/Content/Fonts.css",
            "~/Content/Site.css",
            "~/Content/BundleTransformer.css",
            "~/AlternativeContent/css/TestCssComponentsPaths.css",
            "~/Content/themes/base/jquery.ui.core.css",
            "~/Content/themes/base/jquery.ui.theme.css",
            "~/Content/themes/base/jquery.ui.resizable.css",
            "~/Content/themes/base/jquery.ui.button.css",
            "~/Content/themes/base/jquery.ui.dialog.css",
            "~/Content/TestTranslators.css",
            "~/Content/less/TestLess.less",
            "~/Content/sass/TestSass.sass",
            "~/Content/scss/TestScss.scss");
         commonStylesBundle.Orderer = nullOrderer;

         bundles.Add(commonStylesBundle);

         var modernizrBundle = newCustomScriptBundle("~/Bundles/Modernizr");
         modernizrBundle.Include("~/Scripts/modernizr-2.*");
         modernizrBundle.Orderer = nullOrderer;

         bundles.Add(modernizrBundle);

         var jQueryBundle = newCustomScriptBundle("~/Bundles/Jquery", 
            "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js");
         jQueryBundle.Include("~/Scripts/jquery-{version}.js");
         jQueryBundle.Orderer = nullOrderer;
         jQueryBundle.CdnFallbackExpression = "window.jquery";

         bundles.Add(jQueryBundle);

         var commonScriptsBundle = newCustomScriptBundle("~/Bundles/CommonScripts");
         commonScriptsBundle.Include("~/Scripts/MicrosoftAjax.js",
            "~/Scripts/jquery-ui-{version}.js",
            "~/Scripts/jquery.validate.js",
            "~/Scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.unobtrusive-ajax.js",
            "~/Scripts/knockout-2.*",
            "~/Scripts/coffee/TestCoffeeScript.coffee",
            "~/Scripts/coffee/TestLiterateCoffeeScript.litcoffee",
            "~/Scripts/coffee/TestCoffeeScriptMarkdown.coffee.md",
            "~/Scripts/ts/TranslatorBadge.ts",
            "~/Scripts/ts/ColoredTranslatorBadge.ts",
            "~/Scripts/ts/TestTypeScript.ts");
         commonScriptsBundle.Orderer = nullOrderer;

         bundles.Add(commonScriptsBundle);
         …
      }
   }
}

CustomStyleBundle and CustomScriptBundleсlasses are analogues of the StyleBundle and ScriptBundle classes, oriented to work with the Bundle Transformer.CustomStyleBundle class uses CssTransformer as transformation by default and NullBuilder as builder by default, and CustomScriptBundle class uses JsTransformer as transformation by default andNullBuilder as builder by default.

Example of _Layout.cshtml:

<!DOCTYPEhtml><htmllang="en"><head><metacharset="utf-8"/><title>@ViewBag.Title - Bundle Transformer Example MVC Application</title><linkhref="~/favicon.ico"rel="shortcut icon"type="image/x-icon"/><metaname="viewport"content="width=device-width"/>
      @Styles.Render("~/Bundles/CommonStyles")
      @Scripts.Render("~/Bundles/Modernizr")
   </head><body>
      ...
      @Scripts.Render("~/Bundles/Jquery")
      @Scripts.Render("~/Bundles/CommonScripts")
      @RenderSection("scripts", required: false)
   </body></html>

When adding assets from directory, you can specify patterns for exclusion of unnecessary files (ignorePatterns parameter):

var jqueryUiStylesDirectoryBundle = new Bundle("~/Bundles/JqueryUiStylesDirectory");
jqueryUiStylesDirectoryBundle.Builder = nullBuilder;
jqueryUiStylesDirectoryBundle.IncludeDirectory("~/Content/themes/base/", "*.css");
jqueryUiStylesDirectoryBundle.Transforms.Add(new CssTransformer(
   new[] { "*.all.css", "jquery.ui.base.css" }));

bundles.Add(jqueryUiStylesDirectoryBundle);

var scriptsDirectoryBundle = new Bundle("~/Bundles/ScriptsDirectory");
scriptsDirectoryBundle.Builder = nullBuilder;
scriptsDirectoryBundle.IncludeDirectory("~/Scripts/", "*.js", true);
scriptsDirectoryBundle.Transforms.Add(new JsTransformer(
   new[] { "*.all.js", "references.js" }));

bundles.Add(scriptsDirectoryBundle);

Configuration settings

Starting with version 1.2.1 Beta from the Web.config file has been removed settings of Bundle Transformer, which were default settings. Current settings of Bundle Transformer equivalent to following version of theWeb.config file:

<?xmlversion="1.0"encoding="utf-8"?><configuration><configSections><!-- Declaration of Bundle Transformer configuration section group --><sectionGroupname="bundleTransformer"><sectionname="core"type="BundleTransformer.Core.Configuration.CoreSettings, BundleTransformer.Core"/><sectionname="less"type="BundleTransformer.Less.Configuration.LessSettings, BundleTransformer.Less"/><sectionname="sassAndScss"type="BundleTransformer.SassAndScss.Configuration.SassAndScssSettings, BundleTransformer.SassAndScss"/><sectionname="typeScript"type="BundleTransformer.TypeScript.Configuration.TypeScriptSettings, BundleTransformer.TypeScript"/><sectionname="coffeeScript"type="BundleTransformer.CoffeeScript.Configuration.CoffeeScriptSettings, BundleTransformer.CoffeeScript"/><sectionname="microsoftAjax"type="BundleTransformer.MicrosoftAjax.Configuration.MicrosoftAjaxSettings, BundleTransformer.MicrosoftAjax"/><sectionname="yui"type="BundleTransformer.Yui.Configuration.YuiSettings, BundleTransformer.Yui"/><sectionname="closure"type="BundleTransformer.Closure.Configuration.ClosureSettings, BundleTransformer.Closure"/><sectionname="uglify"type="BundleTransformer.UglifyJs.Configuration.UglifySettings, BundleTransformer.UglifyJs"/><sectionname="packer"type="BundleTransformer.Packer.Configuration.PackerSettings, BundleTransformer.Packer"/><sectionname="csso"type="BundleTransformer.Csso.Configuration.CssoSettings, BundleTransformer.Csso"/></sectionGroup><!-- /Declaration of Bundle Transformer configuration section group --></configSections><system.web><httpHandlers><!-- Declaration of Bundle Transformer HTTP-handlers --><addpath="*.less"verb="GET"type="BundleTransformer.Less.HttpHandlers.LessAssetHandler, BundleTransformer.Less"/><addpath="*.sass"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"/><addpath="*.scss"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"/><addpath="*.coffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.litcoffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.coffee.md"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.ts"verb="GET"type="BundleTransformer.TypeScript.HttpHandlers.TypeScriptAssetHandler, BundleTransformer.TypeScript"/><!-- /Declaration of Bundle Transformer HTTP-handlers --></httpHandlers></system.web><system.webServer><handlers><!-- Declaration of Bundle Transformer HTTP-handlers --><addname="LessAssetHandler"path="*.less"verb="GET"type="BundleTransformer.Less.HttpHandlers.LessAssetHandler, BundleTransformer.Less"resourceType="File" preCondition=""/><addname="SassAssetHandler"path="*.sass"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"resourceType="File" preCondition=""/><addname="ScssAssetHandler"path="*.scss"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"resourceType="File" preCondition=""/><addname="CoffeeScriptAssetHandler"path="*.coffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="LiterateCoffeeScriptAssetHandler"path="*.litcoffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="CoffeeScriptMarkdownAssetHandler"path="*.coffee.md"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="TypeScriptAssetHandler"path="*.ts"verb="GET"type="BundleTransformer.TypeScript.HttpHandlers.TypeScriptAssetHandler, BundleTransformer.TypeScript"resourceType="File" preCondition=""/><!-- /Declaration of Bundle Transformer HTTP-handlers --></handlers></system.webServer><!-- Bundle Transformer configuration settings --><bundleTransformerxmlns="http://tempuri.org/BundleTransformer.Configuration.xsd"><coreenableTracing="false"jsFilesWithMicrosoftStyleExtensions="MicrosoftAjax.js,MicrosoftMvcAjax.js, MicrosoftMvcValidation.js,knockout-$version$.js"useEnableOptimizationsProperty="true"><cssdefaultMinifier="NullMinifier"usePreMinifiedFiles="true"disableNativeCssRelativePathTransformation="false"><minifiers><addname="NullMinifier"type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core"/><addname="MicrosoftAjaxCssMinifier"type="BundleTransformer.MicrosoftAjax.Minifiers.MicrosoftAjaxCssMinifier, BundleTransformer.MicrosoftAjax"/><addname="YuiCssMinifier"type="BundleTransformer.Yui.Minifiers.YuiCssMinifier, BundleTransformer.Yui"/><addname="KryzhanovskyCssMinifier"type="BundleTransformer.Csso.Minifiers.KryzhanovskyCssMinifier, BundleTransformer.Csso"/><addname="WgCssMinifier"type="BundleTransformer.WG.Minifiers.WgCssMinifier, BundleTransformer.WG"/></minifiers><translators><addname="NullTranslator"type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core"enabled="false"/><addname="LessTranslator"type="BundleTransformer.Less.Translators.LessTranslator, BundleTransformer.Less"enabled="true"/><addname="SassAndScssTranslator"type="BundleTransformer.SassAndScss.Translators.SassAndScssTranslator, BundleTransformer.SassAndScss"enabled="true"/></translators></css><jsdefaultMinifier="NullMinifier"usePreMinifiedFiles="true"><minifiers><addname="NullMinifier"type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core"/><addname="MicrosoftAjaxJsMinifier"type="BundleTransformer.MicrosoftAjax.Minifiers.MicrosoftAjaxJsMinifier, BundleTransformer.MicrosoftAjax"/><addname="YuiJsMinifier"type="BundleTransformer.Yui.Minifiers.YuiJsMinifier, BundleTransformer.Yui"/><addname="ClosureRemoteJsMinifier"type="BundleTransformer.Closure.Minifiers.ClosureRemoteJsMinifier, BundleTransformer.Closure"/><addname="ClosureLocalJsMinifier"type="BundleTransformer.Closure.Minifiers.ClosureLocalJsMinifier, BundleTransformer.Closure"/><addname="CrockfordJsMinifier"type="BundleTransformer.JsMin.Minifiers.CrockfordJsMinifier, BundleTransformer.JsMin"/><addname="UglifyJsMinifier"type="BundleTransformer.UglifyJs.Minifiers.UglifyJsMinifier, BundleTransformer.UglifyJs"/><addname="EdwardsJsMinifier"type="BundleTransformer.Packer.Minifiers.EdwardsJsMinifier, BundleTransformer.Packer"/></minifiers><translators><addname="NullTranslator"type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core"enabled="false"/><addname="CoffeeScriptTranslator"type="BundleTransformer.CoffeeScript.Translators.CoffeeScriptTranslator, BundleTransformer.CoffeeScript"enabled="true"/><addname="TypeScriptTranslator"type="BundleTransformer.TypeScript.Translators.TypeScriptTranslator, BundleTransformer.TypeScript"enabled="true"/></translators></js></core><lessuseNativeMinification="false"ieCompat="true"strictMath="false"strictUnits="false"dumpLineNumbers="None"/><sassAndScssuseNativeMinification="false"lineNumbers="false"traceSelectors="false"debugInfo="false"/><coffeeScriptbare="true"/><typeScriptuseDefaultLib="true"propagateEnumConstants="false"removeComments="false"allowAutomaticSemicolonInsertion="true"allowBool="false"noImplicitAny="false"codeGenTarget="EcmaScript3"/><microsoftAjax><cssallowEmbeddedAspNetBlocks="false"blocksStartOnSameLine="NewLine"ignoreAllErrors="false"ignoreErrorList="" indentSize="4"lineBreakThreshold="2147482647"outputMode="SingleLine"preprocessorDefineList="" termSemicolons="false"colorNames="Strict"commentMode="Important"minifyExpressions="true"severity="0"/><jsallowEmbeddedAspNetBlocks="false"blocksStartOnSameLine="NewLine"ignoreAllErrors="false"ignoreErrorList="" indentSize="4"lineBreakThreshold="2147482647"outputMode="SingleLine"preprocessorDefineList="" termSemicolons="false"alwaysEscapeNonAscii="false"collapseToLiteral="true"constStatementsMozilla="false"debugLookupList="Debug,$Debug,WAssert,Msn.Debug,Web.Debug"errorIfNotInlineSafe="false"evalLiteralExpressions="true"evalTreatment="Ignore"ignoreConditionalCompilation="false"ignorePreprocessorDefines="false"inlineSafeStrings="true"knownGlobalNamesList="" localRenaming="CrunchAll"macSafariQuirks="true"manualRenamesProperties="true"noAutoRenameList="$super"preserveFunctionNames="false"preserveImportantComments="true"quoteObjectLiteralProperties="false"removeFunctionExpressionNames="true"removeUnneededCode="true"renamePairs="" reorderScopeDeclarations="true"strictMode="false"stripDebugStatements="true"severity="0"/></microsoftAjax><yui><csscompressionType="Standard"removeComments="true"lineBreakPosition="-1"/><jscompressionType="Standard"obfuscateJavascript="true"preserveAllSemicolons="false"disableOptimizations="false"ignoreEval="false"severity="0"lineBreakPosition="-1"encoding="UTF8"threadCulture="en-us"/></yui><closure><js><remoteclosureCompilerServiceApiUrl="http://closure-compiler.appspot.com/compile"compilationLevel="Simple"prettyPrint="false"excludeDefaultExterns="false"severity="0"/><localjavaVirtualMachinePath="" closureCompilerApplicationPath=""compilationLevel="Simple"prettyPrint="false"languageSpec="EcmaScript3"thirdParty="true"processJqueryPrimitives="false"processClosurePrimitives="false"severity="0"/></js></closure><uglify><jsscrewIe8="false"severity="0"><parsingstrict="false"/><compression compress="true" sequences="true" propertiesDotNotation="true"
          deadCode="true" dropDebugger="true" unsafe="false"
          conditionals="true" comparisons="true" evaluate="true"
          booleans="true" loops="true" unused="true"
          hoistFunctions="true" hoistVars="false" ifReturn="true"
          joinVars="true" cascade="true"
          globalDefinitions="" />
        <manglingmangle="true"except="" eval="false"sort="false"topLevel="false"/><codeGenerationbeautify="false"indentLevel="4"indentStart="0"quoteKeys="false"spaceColon="true"asciiOnly="false"inlineScript="false"width="80"maxLineLength="32000"ieProof="true"bracketize="false"semicolons="true"comments="false"preserveLine="false"/></js></uglify><packer><jsshrinkVariables="true"base62Encode="false"/></packer><csso><cssdisableRestructuring="false"/></csso></bundleTransformer><!-- /Bundle Transformer configuration settings --></configuration>

Also since version 1.2.1 Beta in the Web.config file for thebundleTransformer configuration section was implemented support for IntelliSense (implemented by using XML Schema, which is located in theBundleTransformer.Configuration.xsd file):

IntelliSense support when editing the  bundleTransformer configuration section in the Web.config file

Translators

Bundle Transformer: LESS and Bundle Transformer: LESS Lite

BundleTransformer.Less andBundleTransformer.LessLite contains translator-adapterLessTranslator (supports LESS version 1.4.2). This adapter makes translation of LESS-code to CSS-code. Also contains HTTP-handlerLessAssetHandler, which is responsible for text output of translated LESS-asset.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

Bundle Transformer: Sass and SCSS

BundleTransformer.SassAndScss contains translator-adapterSassAndScssTranslator (based on code of theSassAndCoffee.Ruby library version 2.0.2.0 withRobert Wintermoose's Update and supportsSass version 3.2.10). This adapter makes translation of Sass- and SCSS-code to CSS-code. Also contains HTTP-handlerSassAndScssAssetHandler, which is responsible for text output of translated Sass- or SCSS-asset.

Bundle Transformer: CoffeeScript

BundleTransformer.CoffeeScript contains translator-adapterCoffeeScriptTranslator (supports CoffeeScript version 1.6.3). This adapter makes translation of CoffeeScript-code to JS-code. Also contains HTTP-handlerCoffeeScriptAssetHandler, which is responsible for text output of translated CoffeeScript-asset.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

Bundle Transformer: TypeScript

BundleTransformer.TypeScript contains translator-adapterTypeScriptTranslator (supports TypeScript version 0.9.1.1). This adapter makes translation of TypeScript-code to JS-code. Also contains HTTP-handlerTypeScriptAssetHandler, which is responsible for text output of translated TypeScript-asset.

BundleTransformer.TypeScript does not support external modules (CommonJS and AMD modules).

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

When using the types declared in other files, you need add to code the references to these files by using the "reference" comments, as shown in the following example:

/// <reference path="jquery.d.ts" />/// <reference path="TranslatorBadge.ts" />/// <summary>/// Creates colored badge for translator/// </summary>
;class ColoredTranslatorBadge extends TranslatorBadge {
	public getTextColor(): string {
		/// <summary>/// Gets a text color of badge/// </summary>/// <returns type="String">/// Text color of badge/// </returns>returnthis.$linkElem.css("color"); 
	}

	public setTextColor(color: string): void {
		/// <summary>/// Sets a text color of badge/// </summary>/// <param name="color" type="String">/// Text color of badge/// </param>this.$linkElem.css("color", color);
	}

	public getBorderColor(): string {
		/// <summary>/// Gets a border color of badge/// </summary>/// <returns type="String">/// Border color of badge/// </returns>returnthis.$badgeElem.css("border-color");
	} 

	public setBorderColor(color: string) {
		/// <summary>/// Sets a border color of badge/// </summary>/// <param name="color" type="String">/// Border color of badge/// </param>this.$badgeElem.css("border-color", color);
	}
}

Minifiers

Bundle Transformer: Microsoft Ajax

BundleTransformer.MicrosoftAjax contains 2 minifier-adapters:MicrosoftAjaxCssMinifier (for minification of CSS-code) andMicrosoftAjaxJsMinifier (for minification of JS-code). These adapters perform minification using theMicrosoft Ajax Minifier.

To make MicrosoftAjaxCssMinifier is the default CSS-minifier andMicrosoftAjaxJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In defaultMinifier attribute of \configuration\bundleTransformer\core\css element must be set value equal toMicrosoftAjaxCssMinifier, and in same attribute of\configuration\bundleTransformer\core\js element -MicrosoftAjaxJsMinifier.

Bundle Transformer: YUI

BundleTransformer.Yui contains 2 minifier-adapters:YuiCssMinifier (for minification of CSS-code) andYuiJsMinifier (for minification of JS-code). These adapters perform minification using theYUI Compressor for .NET.

To make YuiCssMinifier is the default CSS-minifier andYuiJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In defaultMinifier attribute of \configuration\bundleTransformer\core\css element must be set value equal toYuiCssMinifier, and in same attribute of\configuration\bundleTransformer\core\js element -YuiJsMinifier.

Bundle Transformer: Closure

BundleTransformer.Closure contains 2 minifier-adapters for minification of JS-code:ClosureRemoteJsMinifier and ClosureLocalJsMinifier. ClosureRemoteJsMinifier is based on the Google Closure Compiler Service API and requires a permanent connection to Internet.ClosureLocalJsMinifier is based on the Google Closure Compiler Application and for their work requires latest version of filecompiler.jar.

To make ClosureRemoteJsMinifier orClosureLocalJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toClosureRemoteJsMinifier or ClosureLocalJsMinifier.

To start using ClosureLocalJsMinifier need to make the following preliminary work:

  1. On your computer must be installed Java 6 or higher. Latest version of Java can be downloaded at the following URL -http://www.java.com/download/.
  2. You need to download latest version of the Google Closure Compiler Application, which is located on the URL - http://closure-compiler.googlecode.com/files/compiler-latest.zip.
  3. Unzip the downloaded archive and copy the file compiler.jar in some directory on disk of your computer.
  4. In Web.config file find the configuration/bundleTransformer/closure/local element, then set the javaVirtualMachinePath attribute to a value equal to the path to executable file of the Java Virtual Machine (java.exe), and set theclosureCompilerApplicationPath attribute to a value equal to the path to JAR-file of the Google Closure Compiler Application (compiler.jar).

Bundle Transformer: JSMin

BundleTransformer.JsMin contains one minifier-adapter for minification of JS-code -CrockfordJsMinifier. CrockfordJsMinifier is based on the C# port of Douglas Crockford's JSMin (version of May 22 2007).

To make CrockfordJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toCrockfordJsMinifier.

Bundle Transformer: UglifyJS

BundleTransformer.UglifyJs contains one minifier-adapter for minification of JS-code -UglifyJsMinifier. UglifyJsMinifier is based on the Mihai Bazon's UglifyJS version 2.3.6.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

To make UglifyJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toUglifyJsMinifier.

Bundle Transformer: Packer

BundleTransformer.Packer contains one minifier-adapter for minification of JS-code -EdwardsJsMinifier. EdwardsJsMinifier is based on the Dean Edwards' Packer version 3.0.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly, it is recommended to install Internet Explorer 9 and above on a server.

To make EdwardsJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toEdwardsJsMinifier.

Bundle Transformer: CSSO

BundleTransformer.Csso contains one minifier-adapter for minification of CSS-code -KryzhanovskyCssMinifier. KryzhanovskyCssMinifier is based on the Sergey Kryzhanovsky's CSSO (CSS Optimizer) version 1.3.7.

As a JS-engine is used the Noesis Javascript .NET. BundleTransformer.Csso in runtime itself switches to correct version of the Noesis Javascript .NET (assemblies for different platforms are located in theApp_Data/Noesis.Javascript directory). For correct working of the Noesis Javascript .NET require assembliesmsvcp100.dll and msvcr100.dll from the Microsoft Visual C++ 2010.

If in your system does not assemblies msvcp100.dll andmsvcr100.dll, then download and install the Microsoft Visual C++ 2010 Redistributable Package (x86, x64)

To make KryzhanovskyCssMinifier is the default CSS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\css element must be set value equal toKryzhanovskyCssMinifier.

Bundle Transformer: WebGrease

BundleTransformer.WG contains one minifier-adapter for minification of CSS-code -WgCssMinifier. WgCssMinifier is based on the WebGrease Semantic CSS-minifier version 1.3.0.

To make WgCssMinifier is the default CSS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\css element must be set value equal toWgCssMinifier.


Updated Wiki: Bundle Transformer 1.7.27

$
0
0

Bundle Transformer 1.7.27

Bundle Transformer logo

Before you read

Before you read the documentation for Bundle Transformer, i recommend to read chapter“Bundling and Minification” of the ASP.NET MVC 4 tutorial and Howard Dierking's article «New Web Optimization Pre-Release Package on NuGet». Also recommend you read the Rick Anderson's posts about using of Microsoft ASP.NET Web Optimization Framework with Web Forms and Web Pages.

Bundle Transformer does not minify HTML markup, embedded/inline styles and scripts. For these purposes it is recommended to useWebMarkupMin.

Examples of usage

Recommend to move the code, that is responsible for the registration of assets, from theGlobal.asax file in the BundleConfig.cs file and place this file in the App_Start directory. In the Global.asax file you need to leave only the code calling a method of classBundleConfig:

using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace BundleTransformer.Example.Mvc
{
   publicclass MvcApplication : System.Web.HttpApplication
   {
      protectedvoid Application_Start()
      {
         AreaRegistration.RegisterAllAreas();

         FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
         RouteConfig.RegisterRoutes(RouteTable.Routes);
         BundleConfig.RegisterBundles(BundleTable.Bundles);
      }
   }
}

Here an example of registration of assets and configuration of their processing with the help ofCssTransformer and JsTransformer in the BundleConfig.cs file:

namespace BundleTransformer.Example.Mvc
{
   using System.Web.Optimization;

   using Core.Builders;using Core.Orderers;using Core.Transformers;publicclass BundleConfig
   {
      publicstaticvoid RegisterBundles(BundleCollection bundles)
      {
         bundles.UseCdn = true;

         var nullBuilder = new NullBuilder();var cssTransformer = new CssTransformer();var jsTransformer = new JsTransformer();var nullOrderer = new NullOrderer();

         var commonStylesBundle = new Bundle("~/Bundles/CommonStyles");
         commonStylesBundle.Include(
            "~/Content/Fonts.css",
            "~/Content/Site.css",
            "~/Content/BundleTransformer.css",
            "~/AlternativeContent/css/TestCssComponentsPaths.css",
            "~/Content/themes/base/jquery.ui.core.css",
            "~/Content/themes/base/jquery.ui.theme.css",
            "~/Content/themes/base/jquery.ui.resizable.css",
            "~/Content/themes/base/jquery.ui.button.css",
            "~/Content/themes/base/jquery.ui.dialog.css",
            "~/Content/TestTranslators.css",
            "~/Content/less/TestLess.less",
            "~/Content/sass/TestSass.sass",
            "~/Content/scss/TestScss.scss");
         commonStylesBundle.Builder = nullBuilder;
         commonStylesBundle.Transforms.Add(cssTransformer);
         commonStylesBundle.Orderer = nullOrderer;

         bundles.Add(commonStylesBundle);

         var modernizrBundle = new Bundle("~/Bundles/Modernizr");
         modernizrBundle.Include("~/Scripts/modernizr-2.*");
         modernizrBundle.Builder = nullBuilder;
         modernizrBundle.Transforms.Add(jsTransformer);
         modernizrBundle.Orderer = nullOrderer;

         bundles.Add(modernizrBundle);

         var jQueryBundle = new Bundle("~/Bundles/Jquery", 
            "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js");
         jQueryBundle.Include("~/Scripts/jquery-{version}.js");
         jQueryBundle.Builder = nullBuilder;
         jQueryBundle.Transforms.Add(jsTransformer);
         jQueryBundle.Orderer = nullOrderer;
         jQueryBundle.CdnFallbackExpression = "window.jquery";

         bundles.Add(jQueryBundle);

         var commonScriptsBundle = new Bundle("~/Bundles/CommonScripts");
         commonScriptsBundle.Include("~/Scripts/MicrosoftAjax.js",
            "~/Scripts/jquery-ui-{version}.js",
            "~/Scripts/jquery.validate.js",
            "~/Scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.unobtrusive-ajax.js",
            "~/Scripts/knockout-2.*",
            "~/Scripts/coffee/TestCoffeeScript.coffee",
            "~/Scripts/coffee/TestLiterateCoffeeScript.litcoffee",
            "~/Scripts/coffee/TestCoffeeScriptMarkdown.coffee.md",
            "~/Scripts/ts/TranslatorBadge.ts",
            "~/Scripts/ts/ColoredTranslatorBadge.ts",
            "~/Scripts/ts/TestTypeScript.ts");
         commonStylesBundle.Builder = nullBuilder;
         commonScriptsBundle.Transforms.Add(jsTransformer);
         commonScriptsBundle.Orderer = nullOrderer;

         bundles.Add(commonScriptsBundle);
         …
      }
   }
}

NullBuilder class is responsible for prevention of early applying of the item transformations and combining of code.CssTransformer and JsTransformer classes produce processing of stylesheets and scripts. NullOrderer class disables the built-in sorting mechanism and save assets sorted in the order they are declared.

Bundle Transformer is not recommended to use together with the StyleBundle and ScriptBundle classes, because these classes already contain transformations (instances of the built-in minifier-transformations:CssMinify and JsMinify). If you are in this situation plug the Bundle Transformer minifiers-modules (for example, BundleTransformer.MicrosoftAjax or BundleTransformer.Yui), then it will lead to a double minification of code. In addition, minifier-modules of the Bundle Transformer do not produce the re-minification of code of pre-minified assets (for example, files with the extension*.min.js and *.min.css), that speeds up the process of optimization.

You also need to understand that when you plug instances of CssTransformer and JsTransformer classes, then you plug in a set of transformations (choice between debug and pre-minified versions of files, translation code from the intermediate languages, runtime code minification, transformation of relative paths to absolute (only for CSS-code) and code combining). A set of transformations depends on what the modules of Bundle Transformer you have installed and settings you have specified in theWeb.config file.

Also note, that CssMinify and JsMinify was created on the basis of the Microsoft Ajax Minifier. Therefore, as a their replacement you can use minifier-module the BundleTransformer.MicrosoftAjax, which supports a newer version of the Microsoft Ajax Minifier algorithm and allows you to make a more fine-tuning of this algorithm.

Above code can be a bit shorter, if you will use the CustomStyleBundle and CustomScriptBundle classes:

namespace BundleTransformer.Example.Mvc
{
   using System.Web.Optimization;

   using Core.Builders;
   using Core.Bundles;using Core.Orderers;
   using Core.Transformers;

   publicclass BundleConfig
   {
      publicstaticvoid RegisterBundles(BundleCollection bundles)
      {
         bundles.UseCdn = true;

         var nullBuilder = new NullBuilder();
         var nullOrderer = new NullOrderer();

         var commonStylesBundle = newCustomStyleBundle("~/Bundles/CommonStyles");
         commonStylesBundle.Include(
            "~/Content/Fonts.css",
            "~/Content/Site.css",
            "~/Content/BundleTransformer.css",
            "~/AlternativeContent/css/TestCssComponentsPaths.css",
            "~/Content/themes/base/jquery.ui.core.css",
            "~/Content/themes/base/jquery.ui.theme.css",
            "~/Content/themes/base/jquery.ui.resizable.css",
            "~/Content/themes/base/jquery.ui.button.css",
            "~/Content/themes/base/jquery.ui.dialog.css",
            "~/Content/TestTranslators.css",
            "~/Content/less/TestLess.less",
            "~/Content/sass/TestSass.sass",
            "~/Content/scss/TestScss.scss");
         commonStylesBundle.Orderer = nullOrderer;

         bundles.Add(commonStylesBundle);

         var modernizrBundle = newCustomScriptBundle("~/Bundles/Modernizr");
         modernizrBundle.Include("~/Scripts/modernizr-2.*");
         modernizrBundle.Orderer = nullOrderer;

         bundles.Add(modernizrBundle);

         var jQueryBundle = newCustomScriptBundle("~/Bundles/Jquery", 
            "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js");
         jQueryBundle.Include("~/Scripts/jquery-{version}.js");
         jQueryBundle.Orderer = nullOrderer;
         jQueryBundle.CdnFallbackExpression = "window.jquery";

         bundles.Add(jQueryBundle);

         var commonScriptsBundle = newCustomScriptBundle("~/Bundles/CommonScripts");
         commonScriptsBundle.Include("~/Scripts/MicrosoftAjax.js",
            "~/Scripts/jquery-ui-{version}.js",
            "~/Scripts/jquery.validate.js",
            "~/Scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.unobtrusive-ajax.js",
            "~/Scripts/knockout-2.*",
            "~/Scripts/coffee/TestCoffeeScript.coffee",
            "~/Scripts/coffee/TestLiterateCoffeeScript.litcoffee",
            "~/Scripts/coffee/TestCoffeeScriptMarkdown.coffee.md",
            "~/Scripts/ts/TranslatorBadge.ts",
            "~/Scripts/ts/ColoredTranslatorBadge.ts",
            "~/Scripts/ts/TestTypeScript.ts");
         commonScriptsBundle.Orderer = nullOrderer;

         bundles.Add(commonScriptsBundle);
         …
      }
   }
}

CustomStyleBundle and CustomScriptBundleсlasses are analogues of the StyleBundle and ScriptBundle classes, oriented to work with the Bundle Transformer.CustomStyleBundle class uses CssTransformer as transformation by default and NullBuilder as builder by default, and CustomScriptBundle class uses JsTransformer as transformation by default andNullBuilder as builder by default.

Example of _Layout.cshtml:

<!DOCTYPEhtml><htmllang="en"><head><metacharset="utf-8"/><title>@ViewBag.Title - Bundle Transformer Example MVC Application</title><linkhref="~/favicon.ico"rel="shortcut icon"type="image/x-icon"/><metaname="viewport"content="width=device-width"/>
      @Styles.Render("~/Bundles/CommonStyles")
      @Scripts.Render("~/Bundles/Modernizr")
   </head><body>
      ...
      @Scripts.Render("~/Bundles/Jquery")
      @Scripts.Render("~/Bundles/CommonScripts")
      @RenderSection("scripts", required: false)
   </body></html>

When adding assets from directory, you can specify patterns for exclusion of unnecessary files (ignorePatterns parameter):

var jqueryUiStylesDirectoryBundle = new Bundle("~/Bundles/JqueryUiStylesDirectory");
jqueryUiStylesDirectoryBundle.Builder = nullBuilder;
jqueryUiStylesDirectoryBundle.IncludeDirectory("~/Content/themes/base/", "*.css");
jqueryUiStylesDirectoryBundle.Transforms.Add(new CssTransformer(
   new[] { "*.all.css", "jquery.ui.base.css" }));

bundles.Add(jqueryUiStylesDirectoryBundle);

var scriptsDirectoryBundle = new Bundle("~/Bundles/ScriptsDirectory");
scriptsDirectoryBundle.Builder = nullBuilder;
scriptsDirectoryBundle.IncludeDirectory("~/Scripts/", "*.js", true);
scriptsDirectoryBundle.Transforms.Add(new JsTransformer(
   new[] { "*.all.js", "references.js" }));

bundles.Add(scriptsDirectoryBundle);

Configuration settings

Starting with version 1.2.1 Beta from the Web.config file has been removed settings of Bundle Transformer, which were default settings. Current settings of Bundle Transformer equivalent to following version of theWeb.config file:

<?xmlversion="1.0"encoding="utf-8"?><configuration><configSections><!-- Declaration of Bundle Transformer configuration section group --><sectionGroupname="bundleTransformer"><sectionname="core"type="BundleTransformer.Core.Configuration.CoreSettings, BundleTransformer.Core"/><sectionname="less"type="BundleTransformer.Less.Configuration.LessSettings, BundleTransformer.Less"/><sectionname="sassAndScss"type="BundleTransformer.SassAndScss.Configuration.SassAndScssSettings, BundleTransformer.SassAndScss"/><sectionname="typeScript"type="BundleTransformer.TypeScript.Configuration.TypeScriptSettings, BundleTransformer.TypeScript"/><sectionname="coffeeScript"type="BundleTransformer.CoffeeScript.Configuration.CoffeeScriptSettings, BundleTransformer.CoffeeScript"/><sectionname="microsoftAjax"type="BundleTransformer.MicrosoftAjax.Configuration.MicrosoftAjaxSettings, BundleTransformer.MicrosoftAjax"/><sectionname="yui"type="BundleTransformer.Yui.Configuration.YuiSettings, BundleTransformer.Yui"/><sectionname="closure"type="BundleTransformer.Closure.Configuration.ClosureSettings, BundleTransformer.Closure"/><sectionname="uglify"type="BundleTransformer.UglifyJs.Configuration.UglifySettings, BundleTransformer.UglifyJs"/><sectionname="packer"type="BundleTransformer.Packer.Configuration.PackerSettings, BundleTransformer.Packer"/><sectionname="csso"type="BundleTransformer.Csso.Configuration.CssoSettings, BundleTransformer.Csso"/></sectionGroup><!-- /Declaration of Bundle Transformer configuration section group --></configSections><system.web><httpHandlers><!-- Declaration of Bundle Transformer HTTP-handlers --><addpath="*.less"verb="GET"type="BundleTransformer.Less.HttpHandlers.LessAssetHandler, BundleTransformer.Less"/><addpath="*.sass"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"/><addpath="*.scss"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"/><addpath="*.coffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.litcoffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.coffee.md"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"/><addpath="*.ts"verb="GET"type="BundleTransformer.TypeScript.HttpHandlers.TypeScriptAssetHandler, BundleTransformer.TypeScript"/><!-- /Declaration of Bundle Transformer HTTP-handlers --></httpHandlers></system.web><system.webServer><handlers><!-- Declaration of Bundle Transformer HTTP-handlers --><addname="LessAssetHandler"path="*.less"verb="GET"type="BundleTransformer.Less.HttpHandlers.LessAssetHandler, BundleTransformer.Less"resourceType="File" preCondition=""/><addname="SassAssetHandler"path="*.sass"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"resourceType="File" preCondition=""/><addname="ScssAssetHandler"path="*.scss"verb="GET"type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss"resourceType="File" preCondition=""/><addname="CoffeeScriptAssetHandler"path="*.coffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="LiterateCoffeeScriptAssetHandler"path="*.litcoffee"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="CoffeeScriptMarkdownAssetHandler"path="*.coffee.md"verb="GET"type="BundleTransformer.CoffeeScript.HttpHandlers.CoffeeScriptAssetHandler, BundleTransformer.CoffeeScript"resourceType="File" preCondition=""/><addname="TypeScriptAssetHandler"path="*.ts"verb="GET"type="BundleTransformer.TypeScript.HttpHandlers.TypeScriptAssetHandler, BundleTransformer.TypeScript"resourceType="File" preCondition=""/><!-- /Declaration of Bundle Transformer HTTP-handlers --></handlers></system.webServer><!-- Bundle Transformer configuration settings --><bundleTransformerxmlns="http://tempuri.org/BundleTransformer.Configuration.xsd"><coreenableTracing="false"jsFilesWithMicrosoftStyleExtensions="MicrosoftAjax.js,MicrosoftMvcAjax.js, MicrosoftMvcValidation.js,knockout-$version$.js"useEnableOptimizationsProperty="true"><cssdefaultMinifier="NullMinifier"usePreMinifiedFiles="true"disableNativeCssRelativePathTransformation="false"><minifiers><addname="NullMinifier"type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core"/><addname="MicrosoftAjaxCssMinifier"type="BundleTransformer.MicrosoftAjax.Minifiers.MicrosoftAjaxCssMinifier, BundleTransformer.MicrosoftAjax"/><addname="YuiCssMinifier"type="BundleTransformer.Yui.Minifiers.YuiCssMinifier, BundleTransformer.Yui"/><addname="KryzhanovskyCssMinifier"type="BundleTransformer.Csso.Minifiers.KryzhanovskyCssMinifier, BundleTransformer.Csso"/><addname="WgCssMinifier"type="BundleTransformer.WG.Minifiers.WgCssMinifier, BundleTransformer.WG"/></minifiers><translators><addname="NullTranslator"type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core"enabled="false"/><addname="LessTranslator"type="BundleTransformer.Less.Translators.LessTranslator, BundleTransformer.Less"enabled="true"/><addname="SassAndScssTranslator"type="BundleTransformer.SassAndScss.Translators.SassAndScssTranslator, BundleTransformer.SassAndScss"enabled="true"/></translators></css><jsdefaultMinifier="NullMinifier"usePreMinifiedFiles="true"><minifiers><addname="NullMinifier"type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core"/><addname="MicrosoftAjaxJsMinifier"type="BundleTransformer.MicrosoftAjax.Minifiers.MicrosoftAjaxJsMinifier, BundleTransformer.MicrosoftAjax"/><addname="YuiJsMinifier"type="BundleTransformer.Yui.Minifiers.YuiJsMinifier, BundleTransformer.Yui"/><addname="ClosureRemoteJsMinifier"type="BundleTransformer.Closure.Minifiers.ClosureRemoteJsMinifier, BundleTransformer.Closure"/><addname="ClosureLocalJsMinifier"type="BundleTransformer.Closure.Minifiers.ClosureLocalJsMinifier, BundleTransformer.Closure"/><addname="CrockfordJsMinifier"type="BundleTransformer.JsMin.Minifiers.CrockfordJsMinifier, BundleTransformer.JsMin"/><addname="UglifyJsMinifier"type="BundleTransformer.UglifyJs.Minifiers.UglifyJsMinifier, BundleTransformer.UglifyJs"/><addname="EdwardsJsMinifier"type="BundleTransformer.Packer.Minifiers.EdwardsJsMinifier, BundleTransformer.Packer"/></minifiers><translators><addname="NullTranslator"type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core"enabled="false"/><addname="CoffeeScriptTranslator"type="BundleTransformer.CoffeeScript.Translators.CoffeeScriptTranslator, BundleTransformer.CoffeeScript"enabled="true"/><addname="TypeScriptTranslator"type="BundleTransformer.TypeScript.Translators.TypeScriptTranslator, BundleTransformer.TypeScript"enabled="true"/></translators></js></core><lessuseNativeMinification="false"ieCompat="true"strictMath="false"strictUnits="false"dumpLineNumbers="None"/><sassAndScssuseNativeMinification="false"lineNumbers="false"traceSelectors="false"debugInfo="false"/><coffeeScriptbare="true"/><typeScriptuseDefaultLib="true"propagateEnumConstants="false"removeComments="false"allowAutomaticSemicolonInsertion="true"allowBool="false"noImplicitAny="false"codeGenTarget="EcmaScript3"/><microsoftAjax><cssallowEmbeddedAspNetBlocks="false"blocksStartOnSameLine="NewLine"ignoreAllErrors="false"ignoreErrorList="" indentSize="4"lineBreakThreshold="2147482647"outputMode="SingleLine"preprocessorDefineList="" termSemicolons="false"colorNames="Strict"commentMode="Important"minifyExpressions="true"severity="0"/><jsallowEmbeddedAspNetBlocks="false"blocksStartOnSameLine="NewLine"ignoreAllErrors="false"ignoreErrorList="" indentSize="4"lineBreakThreshold="2147482647"outputMode="SingleLine"preprocessorDefineList="" termSemicolons="false"alwaysEscapeNonAscii="false"collapseToLiteral="true"constStatementsMozilla="false"debugLookupList="Debug,$Debug,WAssert,Msn.Debug,Web.Debug"errorIfNotInlineSafe="false"evalLiteralExpressions="true"evalTreatment="Ignore"ignoreConditionalCompilation="false"ignorePreprocessorDefines="false"inlineSafeStrings="true"knownGlobalNamesList="" localRenaming="CrunchAll"macSafariQuirks="true"manualRenamesProperties="true"noAutoRenameList="$super"preserveFunctionNames="false"preserveImportantComments="true"quoteObjectLiteralProperties="false"removeFunctionExpressionNames="true"removeUnneededCode="true"renamePairs="" reorderScopeDeclarations="true"strictMode="false"stripDebugStatements="true"severity="0"/></microsoftAjax><yui><csscompressionType="Standard"removeComments="true"lineBreakPosition="-1"/><jscompressionType="Standard"obfuscateJavascript="true"preserveAllSemicolons="false"disableOptimizations="false"ignoreEval="false"severity="0"lineBreakPosition="-1"encoding="UTF8"threadCulture="en-us"/></yui><closure><js><remoteclosureCompilerServiceApiUrl="http://closure-compiler.appspot.com/compile"compilationLevel="Simple"prettyPrint="false"excludeDefaultExterns="false"severity="0"/><localjavaVirtualMachinePath="" closureCompilerApplicationPath=""compilationLevel="Simple"prettyPrint="false"languageSpec="EcmaScript3"thirdParty="true"processJqueryPrimitives="false"processClosurePrimitives="false"severity="0"/></js></closure><uglify><jsscrewIe8="false"severity="0"><parsingstrict="false"/><compression compress="true" sequences="true" propertiesDotNotation="true"
          deadCode="true" dropDebugger="true" unsafe="false"
          conditionals="true" comparisons="true" evaluate="true"
          booleans="true" loops="true" unused="true"
          hoistFunctions="true" hoistVars="false" ifReturn="true"
          joinVars="true" cascade="true"
          globalDefinitions="" />
        <manglingmangle="true"except="" eval="false"sort="false"topLevel="false"/><codeGenerationbeautify="false"indentLevel="4"indentStart="0"quoteKeys="false"spaceColon="true"asciiOnly="false"inlineScript="false"width="80"maxLineLength="32000"ieProof="true"bracketize="false"semicolons="true"comments="false"preserveLine="false"/></js></uglify><packer><jsshrinkVariables="true"base62Encode="false"/></packer><csso><cssdisableRestructuring="false"/></csso></bundleTransformer><!-- /Bundle Transformer configuration settings --></configuration>

Also since version 1.2.1 Beta in the Web.config file for thebundleTransformer configuration section was implemented support for IntelliSense (implemented by using XML Schema, which is located in theBundleTransformer.Configuration.xsd file):

IntelliSense support when editing the  bundleTransformer configuration section in the Web.config file

Translators

Bundle Transformer: LESS and Bundle Transformer: LESS Lite

BundleTransformer.Less andBundleTransformer.LessLite contains translator-adapterLessTranslator (supports LESS version 1.4.2). This adapter makes translation of LESS-code to CSS-code. Also contains HTTP-handlerLessAssetHandler, which is responsible for text output of translated LESS-asset.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly it is recommended to install Internet Explorer 9 and above on a server.

Bundle Transformer: Sass and SCSS

BundleTransformer.SassAndScss contains translator-adapterSassAndScssTranslator (based on code of theSassAndCoffee.Ruby library version 2.0.2.0 withRobert Wintermoose's Update and supportsSass version 3.2.10). This adapter makes translation of Sass- and SCSS-code to CSS-code. Also contains HTTP-handlerSassAndScssAssetHandler, which is responsible for text output of translated Sass- or SCSS-asset.

Bundle Transformer: CoffeeScript

BundleTransformer.CoffeeScript contains translator-adapterCoffeeScriptTranslator (supports CoffeeScript version 1.6.3). This adapter makes translation of CoffeeScript-code to JS-code. Also contains HTTP-handlerCoffeeScriptAssetHandler, which is responsible for text output of translated CoffeeScript-asset.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly it is recommended to install Internet Explorer 9 and above on a server.

Bundle Transformer: TypeScript

BundleTransformer.TypeScript contains translator-adapterTypeScriptTranslator (supports TypeScript version 0.9.1.1). This adapter makes translation of TypeScript-code to JS-code. Also contains HTTP-handlerTypeScriptAssetHandler, which is responsible for text output of translated TypeScript-asset.

BundleTransformer.TypeScript does not support external modules (CommonJS and AMD modules).

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly it is recommended to install Internet Explorer 9 and above on a server.

When using the types declared in other files, you need add to code the references to these files by using the "reference" comments, as shown in the following example:

/// <reference path="jquery.d.ts" />/// <reference path="TranslatorBadge.ts" />/// <summary>/// Creates colored badge for translator/// </summary>
;class ColoredTranslatorBadge extends TranslatorBadge {
	public getTextColor(): string {
		/// <summary>/// Gets a text color of badge/// </summary>/// <returns type="String">/// Text color of badge/// </returns>returnthis.$linkElem.css("color"); 
	}

	public setTextColor(color: string): void {
		/// <summary>/// Sets a text color of badge/// </summary>/// <param name="color" type="String">/// Text color of badge/// </param>this.$linkElem.css("color", color);
	}

	public getBorderColor(): string {
		/// <summary>/// Gets a border color of badge/// </summary>/// <returns type="String">/// Border color of badge/// </returns>returnthis.$badgeElem.css("border-color");
	} 

	public setBorderColor(color: string) {
		/// <summary>/// Sets a border color of badge/// </summary>/// <param name="color" type="String">/// Border color of badge/// </param>this.$badgeElem.css("border-color", color);
	}
}

Minifiers

Bundle Transformer: Microsoft Ajax

BundleTransformer.MicrosoftAjax contains 2 minifier-adapters:MicrosoftAjaxCssMinifier (for minification of CSS-code) andMicrosoftAjaxJsMinifier (for minification of JS-code). These adapters perform minification using theMicrosoft Ajax Minifier.

To make MicrosoftAjaxCssMinifier is the default CSS-minifier andMicrosoftAjaxJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In defaultMinifier attribute of \configuration\bundleTransformer\core\css element must be set value equal toMicrosoftAjaxCssMinifier, and in same attribute of\configuration\bundleTransformer\core\js element -MicrosoftAjaxJsMinifier.

Bundle Transformer: YUI

BundleTransformer.Yui contains 2 minifier-adapters:YuiCssMinifier (for minification of CSS-code) andYuiJsMinifier (for minification of JS-code). These adapters perform minification using theYUI Compressor for .NET.

To make YuiCssMinifier is the default CSS-minifier andYuiJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In defaultMinifier attribute of \configuration\bundleTransformer\core\css element must be set value equal toYuiCssMinifier, and in same attribute of\configuration\bundleTransformer\core\js element -YuiJsMinifier.

Bundle Transformer: Closure

BundleTransformer.Closure contains 2 minifier-adapters for minification of JS-code:ClosureRemoteJsMinifier and ClosureLocalJsMinifier. ClosureRemoteJsMinifier is based on the Google Closure Compiler Service API and requires a permanent connection to Internet.ClosureLocalJsMinifier is based on the Google Closure Compiler Application and for their work requires latest version of filecompiler.jar.

To make ClosureRemoteJsMinifier orClosureLocalJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toClosureRemoteJsMinifier or ClosureLocalJsMinifier.

To start using ClosureLocalJsMinifier need to make the following preliminary work:

  1. On your computer must be installed Java 6 or higher. Latest version of Java can be downloaded at the following URL -http://www.java.com/download/.
  2. You need to download latest version of the Google Closure Compiler Application, which is located on the URL - http://closure-compiler.googlecode.com/files/compiler-latest.zip.
  3. Unzip the downloaded archive and copy the file compiler.jar in some directory on disk of your computer.
  4. In Web.config file find the configuration/bundleTransformer/closure/local element, then set the javaVirtualMachinePath attribute to a value equal to the path to executable file of the Java Virtual Machine (java.exe), and set theclosureCompilerApplicationPath attribute to a value equal to the path to JAR-file of the Google Closure Compiler Application (compiler.jar).

Bundle Transformer: JSMin

BundleTransformer.JsMin contains one minifier-adapter for minification of JS-code -CrockfordJsMinifier. CrockfordJsMinifier is based on the C# port of Douglas Crockford's JSMin (version of May 22 2007).

To make CrockfordJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toCrockfordJsMinifier.

Bundle Transformer: UglifyJS

BundleTransformer.UglifyJs contains one minifier-adapter for minification of JS-code -UglifyJsMinifier. UglifyJsMinifier is based on the Mihai Bazon's UglifyJS version 2.3.6.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly it is recommended to install Internet Explorer 9 and above on a server.

To make UglifyJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toUglifyJsMinifier.

Bundle Transformer: Packer

BundleTransformer.Packer contains one minifier-adapter for minification of JS-code -EdwardsJsMinifier. EdwardsJsMinifier is based on the Dean Edwards' Packer version 3.0.

As a JS-engine is used the MSIE JavaScript Engine for .NET so for it to work properly it is recommended to install Internet Explorer 9 and above on a server.

To make EdwardsJsMinifier is the default JS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\js element must be set value equal toEdwardsJsMinifier.

Bundle Transformer: CSSO

BundleTransformer.Csso contains one minifier-adapter for minification of CSS-code -KryzhanovskyCssMinifier. KryzhanovskyCssMinifier is based on the Sergey Kryzhanovsky's CSSO (CSS Optimizer) version 1.3.7.

As a JS-engine is used the Noesis Javascript .NET. BundleTransformer.Csso in runtime itself switches to correct version of the Noesis Javascript .NET (assemblies for different platforms are located in theApp_Data/Noesis.Javascript directory). For correct working of the Noesis Javascript .NET require assembliesmsvcp100.dll and msvcr100.dll from the Microsoft Visual C++ 2010.

If in your system does not assemblies msvcp100.dll andmsvcr100.dll, then download and install the Microsoft Visual C++ 2010 Redistributable Package (x86, x64)

To make KryzhanovskyCssMinifier is the default CSS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\css element must be set value equal toKryzhanovskyCssMinifier.

Bundle Transformer: WebGrease

BundleTransformer.WG contains one minifier-adapter for minification of CSS-code -WgCssMinifier. WgCssMinifier is based on the WebGrease Semantic CSS-minifier version 1.3.0.

To make WgCssMinifier is the default CSS-minifier, you need to make changes to theWeb.config file. In the defaultMinifier attribute of the \configuration\bundleTransformer\core\css element must be set value equal toWgCssMinifier.

New Post: .less handler failing with stack overflow?

$
0
0
While I can understand this project was probably changed in order to allow for using the latest .less standard, and the dotLess project seems to have stagnated on getting the latest standards supported, making a dependency on installing a correct version of IE is problematic for two reasons:
  1. On servers, admins generally don't care about IE since it is rarely (if ever used), and companies like Rackspace do not bother with security updates to update the browser. Hence the reason our server never got updated past IE8. On our server, we use Firefox when we need a browser from an RDP session, not IE. And of course, being Micr$oft IE, we did update it to IE10 and guess what. Had to reboot the server! Not nice. So our site was offline for 10 minutes in the middle of the night so we could update IE.
  2. Although this does not affect me, there are developers out there using ASP.NET MVC on the Mono platform on Linux, and I am pretty sure dotLess runs there. This new bundle trasnformer has no hope of ever running on Mono, if it relies on external dependencies specific to Microsoft.
So for the time being we have updated IE on our server and we plan to try the new bundle transformer on it, since it appears to work correctly in all our tests. And while I do understand this is an open source project, it does get used by real developers running real sites. So this change will likely have a negative impact for a lot of folks and will end up having one of two results for them; 1) people will stick to the last version using dotLess and 2) someone will fork it and produce a new version that just use dotLess and maintain that.

New Post: Using with CssRewriteUrlTransform

$
0
0
Hmm... I will have to test, as I swear it wasn't doing that for me once debug was false...

Commented Unassigned: Typescript: exporting a class results in "Object reference not set to an instance of an object' [54]

$
0
0
First of all, thank you for all the hard work you've put into this library. You've made it possible for us to use MVC optimization to compile Bootstrap 3.0.

We're also interested in starting to use TypeScript. In one of my initial tests to get a feel for the language, however, I stumbled upon a frustrating error when trying to create exported classes.

It seems that when a class is exported using the 'export' keyword, the translation fails in the InnerTranslate() function of the TypeScriptTranslator.

To demonstrate the problem, I created a small project and [made it available](https://bitbucket.org/Dvde/typescripterror). Could you find the time to find out what is going wrong?

Comments: Still, then why does it throw a NullReferenceException?

Commented Unassigned: Typescript: exporting a class results in "Object reference not set to an instance of an object' [54]

$
0
0
First of all, thank you for all the hard work you've put into this library. You've made it possible for us to use MVC optimization to compile Bootstrap 3.0.

We're also interested in starting to use TypeScript. In one of my initial tests to get a feel for the language, however, I stumbled upon a frustrating error when trying to create exported classes.

It seems that when a class is exported using the 'export' keyword, the translation fails in the InnerTranslate() function of the TypeScriptTranslator.

To demonstrate the problem, I created a small project and [made it available](https://bitbucket.org/Dvde/typescripterror). Could you find the time to find out what is going wrong?

Comments: In the next release I will resolve this problem. In any case, this error is not critical, because is caused by incorrect syntax.
Viewing all 2358 articles
Browse latest View live