Use SCSS style files within AngularDart 5 and Dart 2
- Add a dev dependency to your pubspec.yaml for
sass_builder:^2.0.0
. - Run
pub get
to download the new dependencies. - Create a sass file ex:
lib/app_component.scss
and add some styles to it. - Add a the compiled css stylesheet to your the @Component annotation in
lib/app_component.dart
:styleUrls: const ['app_component.css'],
The css file will be generated by sass_builder during the build process.
If you are using angluar_components. One could simply turn it on:
Create a build.yaml file with the following content :
targets: $default: builders: angular_components|scss_builder: enabled: True
- Use the following convention for the
styleUrl
annotations:styleUrls: const ['app_component.scss.css']
- Write your sass in the
*.scss
files.
With newest versions:
Surprise: In
styleUrls
are in a different CSS filename (not with the.scss.css
extension, just.css
; e.g.app_component.css
, but the styles are inapp_component.scss
).Surprise: In
app_component.scss
, import withoutlib
in the path:
@import 'package:angular_components/app_layout/mixins';
- I am using this command:
pub run build_runner serve --verbose
See with package info:https://github.com/dart-lang/angular_components/issues/374#issuecomment-636344237