{"id":20874994,"url":"https://github.com/servicestack/bundler","last_synced_at":"2025-04-12T17:45:16.584Z","repository":{"id":2389595,"uuid":"3355567","full_name":"ServiceStack/Bundler","owner":"ServiceStack","description":"Compile \u0026 Minify Less/Sass/Stylus/Css/JS/CoffeeScript/LiveScript files. Integrates with MVC and ServiceStack","archived":false,"fork":false,"pushed_at":"2017-06-17T05:16:10.000Z","size":23383,"stargazers_count":264,"open_issues_count":6,"forks_count":61,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-05T16:51:29.861Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.servicestack.net","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"qklabs/qksms","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ServiceStack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-04T21:33:09.000Z","updated_at":"2025-03-04T22:39:42.000Z","dependencies_parsed_at":"2022-09-03T04:31:02.638Z","dependency_job_id":null,"html_url":"https://github.com/ServiceStack/Bundler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2FBundler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2FBundler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2FBundler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2FBundler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ServiceStack","download_url":"https://codeload.github.com/ServiceStack/Bundler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248609541,"owners_count":21132915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T06:40:42.723Z","updated_at":"2025-04-12T17:45:16.560Z","avatar_url":"https://github.com/ServiceStack.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"New Project Update:\r\n\r\n## [ServiceStackVS modern Single Page App Templates!](http://docs.servicestack.net/templates-single-page-apps)\r\n\r\nTo provide the ultimate Single Page App development experience from VS.NET we've developed the gold standard [Angular](https://angular.io) and [React](http://facebook.github.io/react/), [Vue.js](https://vuejs.org) and [Aurelia](http://aurelia.io) Single Page App VS.NET templates for ASP.NET focusing on providing an optimal run-time and development experience using a pre-configured starting project template that leverages the world-class Webpack build ecosystem for optimized debugging, packaging and deployments. \r\n\r\n[![](https://raw.githubusercontent.com/ServiceStack/docs/master/docs/images/ssvs/spa-templates-overview.png)](http://docs.servicestack.net/templates-single-page-apps)\r\n\r\nAll Single Page App templates are available in the [ServiceStackVS VS.NET Extension](https://visualstudiogallery.msdn.microsoft.com/5bd40817-0986-444d-a77d-482e43a48da7).\r\n\r\nIn contrast, this Bundler project below uses a vanilla node.js-based build system configured using plain .txt files and avoids Gulp.js by referencing npm packages directly:\r\n\r\n---\r\n\r\n# Bundler\r\n\r\nBundler is a fast, cross-platform, command-line runner (easily integrated into existing IDEs, inc VS.NET) with optimized support for ASP.NET MVC and ServiceStack that statically **compiles**, **minifies** and **combines** your websites **less**, **sass**, **stylus**, **css**, **coffeescript**, **livescript** and **js** files.\r\n\r\nBundler uses the popular and well-tested javascript libraries in [node's package manager](http://npmjs.org/) for all minification and compilation. This enables it to generate faster and more up-to-date outputs than any other .NET wrapper solution which either uses old .NET ports of node.js or ruby implementations, or they have to invoke external out-of-process [IronRuby](http://www.ironruby.net/) and  JavaScript processes resulting in slower execution - consuming valuable iteration-time on each dev-cycle.\r\n\r\n  - Easy to use! All **.bundle**'s are plain text files which just contain a list of the file names that make up each bundle\r\n  - Includes **VS.NET Integration**! Saving any supported file auto-runs Bundler. Works seamlessly behind-the-scenes while you code\r\n  - Integrates with **ASP.NET MVC** and **ServiceStack**! Includes 1 C# **Bundler.cs** class to seamlessly integrate with web apps\r\n  - Runs outside the context of your ASP.NET website so client scripts can be re-compiled **without restarting** your C# project\r\n  - Can be used with any website project (not only .NET). Includes a **windows** node.exe although all scripts work cross-platform\r\n  - All bundling done at **compile time**, by running the single `bundler.cmd` command - no dependencies needed at runtime\r\n  - Uses a self-contained **node.exe** for all compilation \u0026 minification - designed for maximum runtime and compile time performance\r\n  - All node.js `.js` and C# `.cs` src files used are in plain-text - so can be easily be followed, extended or customized\r\n\r\n## Extremely fast at both Build and Runtime\r\nBundler is extremely fast - uses Googles leading V8 JavaScript engine (inside node.exe). All build scripts use only *pure JavaScript* implementations (uglifyjs, coffee-script, clean-css, etc) allowing all compilation and minification to run in a single process.\r\n\r\n#### Async / Non-Blocking\r\nThe packager is completely **async and non-blocking** - allowing the processing inside each bundle to happen in parallel.\r\n\r\n#### No Runtime overhead\r\nDesigned for maximum runtime performance since no compilation/minification happens at runtime.\r\nEven the generated HTML output is cached in memory (in production mode) - so has effectively no runtime overhead.\r\n\r\n#### Cuts build-time in 1/2\r\nAfter moving to Bundler for all their compilation and minification, [StackOverflow Careers](http://careers.stackoverflow.com/) have reduced their total build times by more than **1/2**! YMMV but if your current .NET-based Compilation/Optimization build-system is slowing you down - definitely tryout Bundler.\r\n\r\n#### Pre-configured Single Page App Starter Template\r\nCheckout [Social Bootstrap Api](https://github.com/ServiceStack/SocialBootstrapApi) for a great starting template to base your next Single Page App on.\r\nIncludes [Twitter Bootstrap](http://twitter.github.com/bootstrap/) + [Backbone.js](http://backbonejs.org/) + ASP.NET MVC + [ServiceStack](https://github.com/ServiceStack/ServiceStack) with Bundler all wired-up with **Twitter** + **Facebook** + HTML Form + Basic and Digest Auth providers ready-to-go out-of-the-box.\r\n\r\n\r\n## Release Notes\r\n\r\n### v1.16 Release Notes\r\n\r\nBundler has added support for [LiveScript](http://livescript.net/) and [Stylus](http://learnboost.github.io/stylus/) thanks to [@legomind](https://github.com/legomind). \r\n\r\nLiveScript is a terse, functionally-inspired language with CoffeeScript roots popular with functional programmers who want to target JS. Whilst Stylus is another creation from JavaScript's code hero [@tjholowaychuk](https://twitter.com/tjholowaychuk), with his take on a terse white-space significant DSL for CSS.\r\n\r\nSASS support has also been vastly improved thanks to the integration efforts of [@michael-misshore](https://github.com/michael-misshore) who updated Bundler's SASS provider to use the more robust `node-sass` implementation.\r\n\r\nIn addition to supporting ASP.NET MVC we've also added first-class support for ServiceStack-only web projects. To reflect this change `Mvc.Bundler.cs` (which contains all MVC and ServcieStack HTML Helper utils) has been renamed to `Bundler.cs` and now sits in the `ServiceStack.Html` namespace. If you're upgrading from an older version of Bundler you may need to update to use the new references.\r\n\r\n### v1.10 Release Notes\r\nThis release is thanks to the hard work of [@fody](https://twitter.com/fody) who implemented both the [VS.NET Extension](https://github.com/ServiceStack/Bundler#bundler-run-on-save-visual-studio-extension) and [advanced bundling options](https://github.com/ServiceStack/Bundler#advanced-options).\r\n\r\n  - Added VS.NET the Bundler Integration via [Bundler's VS.NET Extension](https://github.com/ServiceStack/Bundler#bundler-run-on-save-visual-studio-extension)\r\n  - Added [advanced bundling options](https://github.com/ServiceStack/Bundler#advanced-options) for finer-grain control\r\n    - Lets you skip bundling or minification steps\r\n    - Lets you recursively compile and minify all files in current and sub-directories without having to list them\r\n\r\n## Community Resources\r\n\r\n  - [Using ServiceStack Bundler](http://antonkallenberg.com/2012/07/26/using-servicestack-bundler/) - Fantastic step-by-step guide to enable Bundler in MVC.\r\n\r\n## Install\r\n\r\nTo run you just need a copy of **/bundler** folder in your website host directory. This can be done by cloning this repo or installing via NuGet:\r\n\r\n[![Install-Pacakage ServiceStack.Host.Mvc](https://raw.githubusercontent.com/ServiceStack/Assets/master/img/wikis/bundler/nuget-bundler.png)](https://nuget.org/packages/Bundler)\r\n\r\n*Once installed you can optionally exclude the '/bundler' or '/bundler/node_modules' folders from your VS.NET project since they contain a lot of files (not required to be referenced).*\r\n\r\nBy default bundler looks at **/Content** and **/Scripts** project folders - this can be changed by editing [/bundler/bundler.cmd](https://github.com/ServiceStack/Bundler/blob/master/src/bundler.cmd):\r\n\r\n    node bundler.js ../Content ../Scripts\r\n\r\nNow you can define .bundle files in any of the above folders.\r\n\r\n## Setup a Bundler runner\r\n\r\nYou basically want to run Bundler when a file your website references has changed, so you can see those changes before your next page refresh.\r\nAlthough `bundler.cmd` is just a simple command-line script, there are a few different ways you can run it during development (in order of most productive):\r\n\r\n  1. Automatically on save of a .less, .css, .sass, .js, .coffee and .bundle (after the 2010 VS.NET Extension is installed)\r\n  2. Add an **External Tool** in VS.NET that runs `bundler.cmd`. Optionally assign a short-cut so you can run with 1 key-stroke\r\n  3. Add a Post-Build event to your project to automatically run it at the end of every build\r\n\r\n**Reminder:** If you don't check-in compiled or .min files you should also get your CI build agents run `bundler.cmd` after each build.\r\n\r\n### Installing the Run on Save VS.NET 2010 Extension\r\n\r\nIf you have VS.NET 2010 you should also double-click the `bundler\\vs2010-extension\\BundlerRunOnSave.vsix` package to install Bundler's VS.NET extension which will automatically runs bundler when any .less, .css, .sass, .js, .coffee and .bundle file is saved.\r\n\r\n![Bundler VS.NET Extension installer](http://mono.servicestack.net/files/BundlerRunOnSave.png)\r\n\r\n*Note: You should reboot VS.NET for the changes to take effect*\r\n\r\nOnce installed the **BundlerRunOnSave.vsix** VS.NET extension runs bundler when you save any file in the project with any of the supported extensions .less, .css, .sass, .js, .coffee and .bundle.\r\n\r\n### Create an External Tool inside VS.NET:\r\n\r\nAllows you to run **Alt T + B** (or assign your own short-cut) to re-compile and minify your changed assets without re-building your project:\r\n\r\n![Add External Tool in VS.NET](https://raw.githubusercontent.com/ServiceStack/Assets/master/img/wikis/bundler/external-tools-bundler.png)\r\n\r\n### Run script on post-build event\r\nAlternatively you can run bundler after every successful build. Add the line below to **Properties** \u003e **Build events** \u003e **Post-build event**:\r\n\r\n    \"$(ProjectDir)bundler\\node.exe\" \"$(ProjectDir)bundler\\bundler.js\" \"$(ProjectDir)Content\" \"$(ProjectDir)Scripts\"\r\n\r\n![Add Bundler to VS.NET Post-Build event](https://raw.githubusercontent.com/ServiceStack/Assets/master/img/wikis/bundler/post-build-bundler.png)\r\n\r\n## How it works\r\n\r\nYou define css or js **bundles** (in plain text) that specifies the list of files you wish to bundle together. Running **bundler.cmd** (either as a short-cut key or post-build script) will scan through your **/Content** folder finding all defined **.js.bundle** and **.css.bundle** definition files which it goes through, only compiling and minifying new or modified files.  For illustration an example **app.js.bundle** and **app.css.bundle** text files are defined below:\r\n\r\n**/Scripts/app.js.bundle**\r\n\r\n    js/underscore.js\r\n    js/backbone.js\r\n    js/includes.js\r\n    js/functions.coffee\r\n    js/base.coffee\r\n    bootstrap.js\r\n\r\n**/Content/app.css.bundle**\r\n\r\n    css/reset.css\r\n    css/variables.less\r\n    css/styles.less\r\n    css/sassy.sass\r\n    default.css\r\n\r\nNow everytime you run **/bundler/bundler.cmd** it will scan these files, compiling and minifying any new or changed files.\r\n\r\n## Enable Bundler.cs Html helpers inside view pages\r\n\r\nTo enable MVC or ServiceStack Html helper's add **ServiceStack.Html** namespace to your views base class by editing your Views/Web.config:\r\n\r\n    \u003csystem.web.webPages.razor\u003e\r\n    \u003cpages pageBaseType=\"System.Web.Mvc.WebViewPage\"\u003e\r\n      \u003cnamespaces\u003e\r\n        \u003cadd namespace=\"System.Web.Mvc\" /\u003e\r\n        \u003cadd namespace=\"System.Web.Mvc.Ajax\" /\u003e\r\n        \u003cadd namespace=\"System.Web.Mvc.Html\" /\u003e\r\n        \u003cadd namespace=\"System.Web.Routing\" /\u003e\r\n        \u003cadd namespace=\"ServiceStack.Html\" /\u003e    \u003c!-- Enable Html Extensions --\u003e\r\n      \u003c/namespaces\u003e\r\n    \u003c/pages\u003e\r\n    \u003c/system.web.webPages.razor\u003e\r\n\r\nOnce enabled, you can then reference these bundles in your MVC **_Layout.cshtml** or **View.cshtml** pages with the **@Html.RenderCssBundle()** and **@Html.RenderJsBundle()** helpers:\r\n\r\n## Bundle Options\r\n\r\nThe different BundleOptions supported are:\r\n\r\n```csharp\r\npublic enum BundleOptions\r\n{\r\n    Normal,              // Left as individual files, references pre-compiled .js / .css files\r\n    Minified,            // Left as individual files, references pre-compiled and minified .min.js / .min.css files\r\n    Combined,            // Combined into single unminified app.js / app.css file\r\n    MinifiedAndCombined  // Combined and Minified into a single app.min.js / app.min.css file\r\n}\r\n```\r\n\r\nWith the above bundle configurations, the following helpers below:\r\n\r\n    @Html.RenderJsBundle(\"~/Scripts/app.js.bundle\", BundleOptions.MinifiedAndCombined)\r\n    @Html.RenderCssBundle(\"~/Content/app.css.bundle\", BundleOptions.Minified)\r\n\r\nWill generate the following HTML:\r\n\r\n    \u003cscript src=\"/Scripts/app.min.js?b578fa\" type=\"text/javascript\"\u003e\u003c/script\u003e\r\n\r\n    \u003clink href=\"/Content/css/reset.min.css?b578fa\" rel=\"stylesheet\" /\u003e\r\n    \u003clink href=\"/Content/css/variables.min.css?b578fa\" rel=\"stylesheet\" /\u003e\r\n    \u003clink href=\"/Content/css/styles.min.css?b578fa\" rel=\"stylesheet\" /\u003e\r\n    \u003clink href=\"/Content/css/sassy.min.css?b578fa\" rel=\"stylesheet\" /\u003e\r\n    \u003clink href=\"/Content/default.min.css?b578fa\" rel=\"stylesheet\" /\u003e\r\n\r\nNote: the **?b578fa** suffix are *cache-breakers* added to each file, so any changes invalidates local brower caches - important if you end up hosting your static assets on a CDN.\r\n\r\nYou can rewrite the generated urls (e.g. to use a CDN instead) by injecting your own [Bundler.DefaultUrlFilter](https://github.com/ServiceStack/Bundler/blob/master/NuGet/Bundler/content/Bundler.cs#L32).\r\n\r\n## Advanced Options \r\n\r\n### Bundle file options\r\n\r\nAdvanced options can be specified that changes how .bundle's are processed. You can specify bundler options following these rules:\r\n\r\n  - Options must be specified on the **first line** of the `.bundle` file, starting with `#options `.\r\n  - Options are comma-delimited. Each option is a key/value pair separated by a colon. Keys are case-insensitive.\r\n  - You can omit the value for boolean options - specified options without a value are set to true.\r\n\r\n#### Example file with options\r\n\r\n    #options nobundle,skipmin\r\n    css/reset.css\r\n    css/variables.less\r\n    default.css\r\n\r\nThe currently available options are:\r\n\r\n  - **nobundle** - Compiles and minifies all files listed, however it does not bundle them into a single file. This allows you to compile and minify your standalone files without concatenating them into a bundle.\r\n  - **skipmin** - Skips the minimization step for every file\r\n  - **skipremin** - Skips the minification step for files that already contain a '.min.' or '.pack.' in their filename. This lowers the chance of multiple minification iterations introducing problems.\r\n  - **folder** - Used as a trigger to transform all files in the folder with this bundle file. If the `recursive` value is used, a seek will search recursively from this root transforming all files in all folders searched. When the `folder` option is used, the `nobundle` option is automatically set. When the `folder` option is used, listing files in the bundle file does nothing.\r\n  - **outputbundleonly** - Does not create individual .min files for each file in the bundle. The bundled file is the only output.\r\n  - **bundleminonly** - Does not create a non-minimized version of the bundle file. Only creates the .min version of the bundle.\r\n\r\nTip: If you just want bundler to transform all the files in your content folder, add a bundle file in the root of the content folder and set its contents to the following:\r\n\r\n    #options folder:recursive\r\n\r\n## Development\r\n\r\nThe Bundler VS.NET extension lives in [/src/vs/BundlerRunOnSave](https://github.com/ServiceStack/Bundler/blob/master/src/vs/BundlerRunOnSave) which requires the VS.NET templates provided by the [Visual Studio 2010 SP1 SDK](http://www.microsoft.com/en-us/download/details.aspx?id=21835) in order to open it.\r\n\r\n## Contributors\r\nA big thanks to all of Bundler's contributors:\r\n\r\n - [mythz](https://github.com/mythz) (Demis Bellot)\r\n - [nicklarsen](https://github.com/NickLarsen) (Nick Larsen)\r\n - [duncansmart](https://github.com/duncansmart) (Duncan Smart)\r\n - [phillip-haydon](https://github.com/phillip-haydon) (Phillip Haydon)\r\n - [cyberlane](https://github.com/Cyberlane) (Justin Nel)\r\n - [isochronous](https://github.com/isochronous)\r\n - [mjibson](https://github.com/mjibson) (Matt Jibson)\r\n - [dixon](https://github.com/dixon) (Jarrod Dixon)\r\n - [michael-wolfenden](https://github.com/michael-wolfenden) (Michael Wolfenden)\r\n - [garjitech](https://github.com/garjitech) (Garrett Wolf)\r\n - [isochronous](https://github.com/isochronous) (Jeremy McLeod)\r\n - [legomind](https://github.com/legomind)\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fservicestack%2Fbundler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fservicestack%2Fbundler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fservicestack%2Fbundler/lists"}