Skip to content

rwasef1830/BundlerMinifier

 
 

Repository files navigation

Bundler and Minifier

Nuget

A .NET Core tool that let's you configure bundling and minification of JS, CSS and HTML files. This is a simplified fork of https://github.com/madskristensen/BundlerMinifier that is kept more up-to-date with NUglify and implements some missing features. It has been repackaged into a .NET Core tool.

GitHub actions have been setup such that new NuGet releases of NUglify will automatically trigger a release and publish of this tool with an incremented version number, so this tool should track NUglify fairly closely. Enjoy! 👍

Install it by running dotnet tool install BundlerMinifier.Core.Tool Invoke it by calling dotnet tool run bundle.


Features

  • Bundles CSS, JavaScript or HTML files into a single output file
  • Support for globbing patterns
  • Minify individual or bundled CSS, JavaScript and HTML files
  • Minification options for each language is customizable
  • Command line support
  • Shortcut to update all bundles in solution
  • Suppress output file generation
  • Support NUglify killSwitch and ignoreErrorList directives for each bundle.
  • A bundle can refer to the output file path of another bundle to include its input files (supports recursion).
  • Bundles are processed in parallel for a faster build.

A note about encoding

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

bundleconfig.json

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

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

[
  {
    "outputFileName": "output/bundle.css",
    "inputFiles": [
      "css/lib/**/*.css", // globbing patterns are supported
      "css/input/site.css"
    ],
    "minify": {
        "enabled": true,
        "commentMode": "all",
        "renameLocals": true,
        "ignoreErrorList": "JS1292,JS1315",
        "gzip": true
    }
  },
  {
    "outputFileName": "output/all.js",
    "inputFiles": [
      "js/*.js",
      "!js/ignore.js" // start with a ! to exclude files
    ]
  },
  {
    "outputFileName": "output/app.js",
    "inputFiles": [
      "input/main.js",
      "input/core/*.js" // all .js files in input/core/
    ]
  }
]

There are some additional values that are possible in the minify section, see src/BundlerMinifier.Core/Minify/JavaScriptOptions.cs and src/BundlerMinifier.Core/Minify/CssOptions.cs for the complete list.

Contribute

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

License

Apache 2.0

About

.NET Core tool that implements bundling and minification. Simplified and repackaged fork of https://github.com/madskristensen/BundlerMinifier

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.2%
  • Other 0.8%