-
Notifications
You must be signed in to change notification settings - Fork 1.5k
SquishIt with Nancy
SquishIt is an asset processing project that helps speed up your Nancy website by combining and minifying your CSS, JavaScript, LESS and Coffeescript files.
https://github.com/jetheredge/SquishIt
You can read an introduction to SquishIt on the authors blog, here:
http://www.codethinked.com/squishit-the-friendly-aspnet-javascript-and-css-squisher
To use with NancyFX you first want to install the NuGet package to your project
Install-Package SquishIt
You create "bundles" of your asset files, as per the above introduction blog post.
Rather than create a Global.asax file in your project you do your wiring up of bundles in the ApplicationStart of your Nancy Bootstrapper.
In release mode, SquishIt will write your minified files to disk. In shared hosting or in production this can cause problems or additional steps to your deployment scripts to assign folder permissions.
Following the approach listed here:
You can create an asset module to handle serving files from memory:
In certain scenarios you don't want un-authenticated users to get access to all your assets. You would construct your asset module like:
Get["/admin/js/{name}"] = parameters =>
{
this.RequiresAuthentication();
this.RequiresClaims(new[] {"Admin"});
return CreateResponse(Bundle.JavaScript().RenderCached((string) parameters.name), Configuration.Instance.JavascriptMimeType);
};
Get["/admin/css/{name}"] = parameters =>
{
this.RequiresAuthentication();
this.RequiresClaims(new[] { "Admin" });
return CreateResponse(Bundle.Css().RenderCached((string)parameters.name), Configuration.Instance.CssMimeType);
};
- Introduction
- Exploring the Nancy module
- Routing
- Taking a look at the DynamicDictionary
- Async
- View Engines
- Using Models
- Managing static content
- Authentication
- Lifecycle of a Nancy Application
- Bootstrapper
- Adding a custom FavIcon
- Diagnostics
- Generating a custom error page
- Localization
- SSL Behind Proxy
- Testing your application
- The cryptography helpers
- Validation
- Hosting Nancy with ASP.NET
- Hosting Nancy with WCF
- Hosting Nancy with Azure
- Hosting Nancy with Suave.IO
- Hosting Nancy with OWIN
- Hosting Nancy with Umbraco
- Hosting Nancy with Nginx on Ubuntu
- Hosting Nancy with FastCgi
- Self Hosting Nancy
- Implementing a Host
- Accessing the client certificate when using SSL
- Running Nancy on your Raspberry Pi
- Running Nancy with ASP.NET Core 3.1