Skip to content
Shannon Deminick edited this page Aug 25, 2017 · 11 revisions

Install

Currently supporting .NET Core 1.0 (netstandard1.6) and .NET 4.5.2

Nuget:

Install-Package Smidge

In Startup.ConfigureServices:

//You can pass in an IConfiguration instance here which contains the Smidge configuration
//values, alternatively you can use a separate smidge.json file (see below)
services.AddSmidge(/* optional IConfiguration parameter */);

You can customize Smidge's global configuration here too, for example you can

  • change the default pipeline
  • register a callback to modify the default pipeline for a given file
  • set the default BundleOptions for Debug or Production environments

Example:

services.AddSmidge(_config)
    .Configure<SmidgeOptions>(options =>
    {
        //specify callback for filtering the pipeline for a given web file:
        options.PipelineFactory.OnGetDefault = GetDefaultPipelineFactory;
        //change some of the bundle options for rendering in Debug mode:
        options.DefaultBundleOptions.DebugOptions.SetCacheBusterType<AppDomainLifetimeCacheBuster>();
        options.DefaultBundleOptions.DebugOptions.FileWatchOptions.Enabled = true;
        //change some of the bundle options for rendering in Production mode:
        options.DefaultBundleOptions.ProductionOptions.SetCacheBusterType<AppDomainLifetimeCacheBuster>();
    });

In Startup.Configure

app.UseSmidge(/* delegate for creating bundles goes here */);

The configuration format for Smidge is as follows. You can either include this structure in your own configuration file and pass in the IConfiguration reference to the AddSmidge method above or add a config file to your app root (not wwwroot) called smidge.json:

{
    "dataFolder": "App_Data/Smidge",
    "version":  "1"
}
  • dataFolder: where the cache files are stored
  • version: can be any string, this is used for cache busting in URLs generated

Create a file in your ~/Views folder: _ViewImports.cshtml (This is an ASP.NET MVC Core way of injecting services into all of your views) In _ViewImports.cshtml add an injected service and a reference to Smidge's tag helpers:

@inject Smidge.SmidgeHelper Smidge
@addTagHelper *, Smidge

NOTE: There is a website example project in this source for a reference: https://github.com/Shazwazza/Smidge/tree/master/src/Smidge.Web

Clone this wiki locally