Discussion:
[dart-misc] less_dart and relative paths
Gonzalo Chumillas
2016-06-06 18:34:08 UTC
Permalink
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.
--
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+***@dartlang.org.
Jan Mostert
2016-06-06 20:01:03 UTC
Permalink
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 <***@____.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';
Post by Gonzalo Chumillas
Is anyone using "less css" in a dart project? How can I specify relative
@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.
--
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
--
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+***@dartlang.org.
Gonzalo Chumillas
2016-06-09 08:25:16 UTC
Permalink
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:
http://lesscss.org/usage/
Post by Gonzalo Chumillas
Is anyone using "less css" in a dart project? How can I specify relative
@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.
--
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+***@dartlang.org.
Gonzalo Chumillas
2016-06-12 17:13:35 UTC
Permalink
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
Post by Gonzalo Chumillas
Is anyone using "less css" in a dart project? How can I specify relative
@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.
--
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+***@dartlang.org.
Jan Mostert
2016-06-13 05:54:57 UTC
Permalink
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
Post by Gonzalo Chumillas
I discover that the "--relative-urls" flag isn't relative to the file
location, but to the project location. The following transformer directive
entry_points: ['web/styles/main.less',
'lib/component/main_component.less', 'lib/component/login_component.less']
- --relative-urls
Post by Gonzalo Chumillas
Is anyone using "less css" in a dart project? How can I specify relative
@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.
--
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
--
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+***@dartlang.org.
Loading...