Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
/ sass-task Public archive

A simple build task for compiling Sass files in your MSBuild project

License

Notifications You must be signed in to change notification settings

marinasundstrom/sass-task

Repository files navigation

Sass Task

A simple build task for compiling Sass files in your MSBuild project.

Easy to configure via familiar JSON-based config file.

Cross-platform alternative to the WebCompiler.

Prerequisites

  • .NET Core SDK 3 or later, or .NET Framework 4.7.2 or later.
  • Latest version of Sass installed on your computer.

Usage

Just add a reference to the SassTask package in your project.

dotnet add package SassTask --version 0.2.0-*

The build task is then automatically imported.

Example file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <SassConfigPath Condition="'$(Configuration)'=='Debug'">sassconfig.debug.json</SassConfigPath>
    <SassConfigPath Condition="'$(Configuration)'=='Release'">sassconfig.json</SassConfigPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="SassTask" Version="0.2.0-*" PrivateAssets="All" />
  </ItemGroup>

</Project>

Configuration

The file extensions recogzined by the build task are .sass and .scss.

Configuration file

The build task can be confgured in the sassconfig.json file. By default, it is expected to be in the project directory.

The default settings are:

{
    "compilerOptions": {
      "style": "expanded",
      "update": false,
      "sourceMap": true,
      "sourceMapUrls": "relative",
      "embedSources": false,
      "embedSourceMap": false,
      "sourceDir": ".",
      "outDir": "."
    },
    "files": undefined
}

Properties

  • compilerOptions
    • style ("expanded" | "compressed") - the style of the output.
    • update - indicating that only files that have changed should be compiled.
    • sourceMap - indicating whether a source map should be created or not.
    • sourceMapUrls ("relative" | "absolute") - the type of paths to source files.
    • embedSources - embed sources in the resulting CSS-files.
    • embedSourceMap - embed source map in the resulting CSS-files.
    • sourceDir - the directory in which the sass-files are located.
    • outDir - the directory to output css-files in.
  • files - an array of file paths that will be exclusively included as input. Wildcards are accepted.

Build

To build this solution:

  1. Install .NET Core CLI 3.0.0 or greater. See https://dot.net/core for download links.
  2. Run ./build.ps1 in PowerShell or ./build.sh from Bash.

About

A simple build task for compiling Sass files in your MSBuild project

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published