less_dart and relative paths

111 views
Skip to first unread message

Gonzalo Chumillas

unread,
Jun 6, 2016, 2:36:45 PM6/6/16
to Dart Misc
Is anyone using "less css" in a dart project? How can I specify relative paths? For example:

@import 'my_file.less';

instead of

@import 'packages/my_app/path1/path2/path3/my_file.less';

Is it something that can be configured in the pubspec.yaml file? I tried the "--relative-urls" directive with no luck. It is tedious to write absolute paths again an again in all my files.
Thanks and sorry my basic English.

Jan Mostert

unread,
Jun 6, 2016, 4:01:20 PM6/6/16
to Dart Misc
I'm using less_dart in two projects if this is the plugin you're referring to, this is my config:

name: '____'
version: 0.0.1
description: _____
author: Jan Vladimir Mostert <jan@____.com>
homepage: _______
environment:
sdk: '>=1.0.0 <2.0.0'
dependencies:
...
less_dart: any
...
transformers:
- dart_to_js_script_rewriter
- $dart2js:
commandLineOptions: [--enable-experimental-mirrors]
- less_dart:
entry_points: [web/styles/main.less, web/styles/test.less]
build_mode: dart

Then in my main.less file, I simply include all the other files I want to include:

@import 'web/styles/bootstrap/bootstrap.less';
@import 'web/styles/bootjack-calendar/calendar.less';










--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Gonzalo Chumillas

unread,
Jun 9, 2016, 4:25:16 AM6/9/16
to Dart Misc
I solved this problem partially. Definitively, --relative-urls does not work, so I used a combination of --rootpath and --include-path in the pubspec.yaml file:

transformers:
- less_dart:
    other_flags:
    - --rootpath=packages/project_name/path/to/assets/
    - --include-path=packages/project_name/path/to/assets/

More info about these directives here:

Gonzalo Chumillas

unread,
Jun 12, 2016, 1:13:36 PM6/12/16
to Dart Misc
I discover that the "--relative-urls" flag isn't relative to the file location, but to the project location. The following transformer directive works well now (entry_points is important and must be declared):

transformers:

- less_dart:
    entry_points
: ['web/styles/main.less', 'lib/component/main_component.less', 'lib/component/login_component.less']
    other_flags
:
   
- --relative-urls


El lunes, 6 de junio de 2016, 20:36:45 (UTC+2), Gonzalo Chumillas escribió:

Jan Mostert

unread,
Jun 13, 2016, 1:55:10 AM6/13/16
to Dart Misc
Mine works just like that without the relative urls flag.
Entry points needs to be specified and build_mode: dart is required as well

See: https://stackoverflow.com/questions/27895919/using-less-in-a-polymer-dart-application




--
Reply all
Reply to author
Forward
0 new messages