hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

scss-sass.md (2218B)

    1 ---
    2 title: SASS / SCSS
    3 description: Hugo Pipes allows the processing of SASS and SCSS files.
    4 date: 2018-07-14
    5 publishdate: 2018-07-14
    6 lastmod: 2018-07-14
    7 categories: [asset management]
    8 keywords: []
    9 menu:
   10   docs:
   11     parent: "pipes"
   12     weight: 30
   13 weight: 02
   14 sections_weight: 02
   15 draft: false
   16 ---
   17 
   18 
   19 Any SASS or SCSS file can be transformed into a CSS file using `resources.ToCSS` which takes two arguments, the resource object and a map of options listed below.
   20 
   21 ```go-html-template
   22 {{ $sass := resources.Get "sass/main.scss" }}
   23 {{ $style := $sass | resources.ToCSS }}
   24 ```
   25 
   26 ### Options
   27 
   28 transpiler [string] {{< new-in "0.80.0" >}}
   29 
   30 : The `transpiler` to use, valid values are `libsass` (default) and `dartsass`. Note that the Embedded Dart Sass project is still in beta. We will try to improve the installation process when it has stable releases, but if you want to use Hugo with Dart Sass you need to download a release binary from [Embedded Dart Sass](https://github.com/sass/dart-sass-embedded/releases) (Hugo after 0.81.0 requires beta 6 or newer) and make sure it's in your PC's `$PATH` (or `%PATH%` on Windows).
   31 
   32 targetPath [string]
   33 : If not set, the resource's target path will be the asset file original path with its extension replaced by `.css`.
   34 
   35 outputStyle [string]
   36 : Default is `nested` (LibSass) and `expanded` (Dart Sass). Other available output styles for LibSass are `expanded`, `compact` and `compressed`. Dart Sass only supports `expanded` and `compressed`.
   37 
   38 precision [int]
   39 : Precision of floating point math. **Note:** This option is not supported by Dart Sass.
   40 
   41 enableSourceMap [bool]
   42 : When enabled, a source map will be generated.
   43 
   44 includePaths [string slice]
   45 : Additional SCSS/SASS include paths. Paths must be relative to the project directory.
   46 
   47 ```go-html-template
   48 {{ $options := (dict "targetPath" "style.css" "outputStyle" "compressed" "enableSourceMap" (not hugo.IsProduction) "includePaths" (slice "node_modules/myscss")) }}
   49 {{ $style := resources.Get "sass/main.scss" | resources.ToCSS $options }}
   50 ```
   51 
   52 {{% note %}}
   53 Setting `outputStyle` to `compressed` will handle SASS/SCSS files minification better than the more generic [`resources.Minify`]({{< ref "minification">}}).
   54 {{% /note %}}