Tóm Tắt
Command Line
Dart Sass’s stand-alone command-line executable uses the blazing-fast Dart VM to compile your stylesheets. To install Dart Sass on the command line, check out the installation instructions. Once you’ve got it running, you can use it compile files:
sass source
/index.scss css/index.css
See sass --help
for additional information on the command-line interface.
Dart Library
You can also use Dart Sass as a Dart library to get the speed of the Dart VM plus the ability to define your own functions and importers. To add it to an existing project:
-
Install the Dart SDK. Make sure its
bin
directory is on yourPATH
. -
Create a
pubspec.yaml
file like this:
name
:
my_project
dev_dependencies
:
sass
:
^1.56.1
-
Run
dart pub get
. -
Create a
compile-sass.dart
file like this:
import
'dart:io'
;
import
'package:sass/sass.dart'
as
sass
;
void
main
(
List
<
String
>
arguments
)
{
var
result
=
sass
.
compile
(
arguments
[
0
]);
new
File
(
arguments
[
1
]).
writeAsStringSync
(
result
);
}
- You can now use this to compile files:
dart compile-sass.dart styles.scss styles.css