dart-league / dart-sass

Sass-transformer for pub-serve and pub-build
MIT License
12 stars 8 forks source link

Build Status

Sass integration for pub

Sass-transformer for pub-serve and pub-build.

Usage

Simply add the following lines to your pubspec.yaml:

dependencies:
  dart_sass_transformer: any
transformers:
  - dart_sass_transformer

After adding the transformer your .sass and .scss files will be automatically transformed to corresponding .css files.

You need to have Sass installed and available on the path.

Configuration

You can also pass options to Sass if necessary:

transformers:
  - dart_sass_transformer:
      executable: /path/to/sass     # Sass executable to use
      compass: true                 # Include compass
      line-numbers: true            # Include line numbers in output
      style: compact                # Style of generated CSS
      copy-sources: true            # Copy original .scss/.sass files to output directory

Using SassC

You can use SassC instead of normal Sass by specifying executable as 'sassc' (or any path ending with 'sassc'):

transformers:
  - dart_sass_transformer:
      executable: sassc  # or /path/to/sassc

SassC only supports .scss-files and does not support Compass.

Inlined transformer

Normally the transformer simply asks Sass to process the primary input files and Sass will then read the dependent inputs from file system. However, if the input files for Sass are themselves produced by other transformers, they might not exist on the file system at all. The normal transformer will not work in those cases.

To work around this problem, you can use inlined_sass_transformer. It will use Barback's APIs to read and inline all imports into one big Sass file which it will then pass to Sass. The downside is that line numbers on error messages and source maps might be incorrect. (See Issue #4 for details.)

To enable the use of inlined transformer, use sass/inlined_sass_transformer as your transformer:

transformers:
  - dart_sass_transformer/inlined_sass_transformer
      <possible configuration settings>

Current limitations