Giter VIP home page Giter VIP logo

aspnetcore.sasscompiler's Introduction

AspNetCore.SassCompiler

NuGet Version

Sass Compiler Library for .NET Core 3.1/5.x./6.x without node.

Installation

The installation of this package is quite simple, you can install this package using NuGet with the following command:

# Package Manager
PM> Install-Package AspNetCore.SassCompiler

# .NET CLI
dotnet add package AspNetCore.SassCompiler

Configuration

After adding the package, the Sass styles from the SourceFolder (defaults to: Styles) will automatically be compiled into .css files in the TargetFolder (defaults to: wwwroot\css) on build. You can also adjust the default (--style=compressed) dart-sass Arguments in the appsettings.json. Scoped CSS is also supported for applications that use blazor for example. This feature is enabled by default and will use the default scoped CSS folders as shown below. To disable this feature, change GenerateScopedCss to false. To adjust any of the default configuration, please add one or more of the following settings to the appsettings.json:

{
  "SassCompiler": {
    "SourceFolder": "Styles",
    "TargetFolder": "wwwroot/css",
    "Arguments": "--style=compressed",
    "GenerateScopedCss": true,
    "ScopedCssFolders": ["Views", "Pages", "Shared", "Components"]
  }
}

Sass watcher

To use the Sass watcher in your project, you must add the following code to your startup.cs:

public void ConfigureServices(IServiceCollection services) 
{
  
#if DEBUG
  services.AddSassCompiler();
#endif

}

We recommend adding the #if DEBUG statement to only use a watcher during debug mode.

Note: The Sass watcher is currently not supported inside of a docker container. This should only be an issue when you're developing inside of a docker container, running the published application in docker is supported as the compiler is automatically run during the MSBuild publish step. See this issue for the progress.

Publish

This library also includes an MSBuild task that runs during the publish of your application. Because of this you don't need to include the Sass Watcher in your release builds and you can safely add the generated .css files to the .gitignore file as they are regenerated during publish.

Examples

To provide you with examples, a configured version of a .NET 5.0 project and a configured .NET 6.0 Blazor app are added in the /Samples folder. Please see the link below for quick access

.NET Core 3.1

.NET 5.0

.NET 6.0 / Blazor

aspnetcore.sasscompiler's People

Contributors

koenvzeijl avatar michaelvs97 avatar sleeuwen avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.