How to use SASS in the Dart Editor

Does anyone have a canned solution for integrating SASS or another CSS preprocessor into a Dart editor? It seems that a special build.dart file is required, which I would rather copy than the code. Thanks.

+6
source share
3 answers

I came across this a few days ago

Pub Sass Integration

+4
source

Here is the build.dart file with basic SASS support:

import 'dart:io'; void main(List<String> args) { for (String arg in args) { if (arg.startsWith('--changed=')) { String file = arg.substring('--changed='.length); if (file.endsWith('.scss')) { var result = Process.runSync('sass', [ '--line-numbers', file, file.substring(0, file.length - '.scss'.length) + '.css']); if (result.exitCode != 0) { // report error (SASS seems to only report first error) // split error lines var lines = result.stderr.split('\n'); // escape quotes in error message on first line var error = lines[0].replaceAll('"', r'\"'); // extract line number from second line var numMatch = new RegExp(r'\d+').firstMatch(lines[1]); var lineNum = numMatch == null ? 1 : num.parse(numMatch.group(0)); // Report error via JSON print('[{"method":"error","params":{"file":"$file","line":$lineNum,"message":"$error"}}]'); } } } } } 
+2
source

During development (with the Dart editor or another editor ...) just use sass, as it should have been used, in your project in the directory:

 sass -w . 

Put the generated CSS files in the ignore list of your source control system (aka .gitignore for git).

And to compile dart2js use the sass pub package: http://pub.dartlang.org/packages/sass

+1
source

All Articles