less-plugin-glob icon indicating copy to clipboard operation
less-plugin-glob copied to clipboard

Globbing Pattern seems wrong

Open danpottshimself opened this issue 8 years ago • 9 comments

so when I am trying to import a collection of less files into a sort of main less file, the globbing pattern does not work as it normally does.

star is my key for asterix * starstar is two **

You would expect this to work: @import "starstar/shared"; @import "starstar/phone"; @import "**/tablet";

The above would then go through all directories and sub-directories to find the files that match shared, phone and tablet. however, it does not.

When i use single stars (see below) it goes into the next directory and no further. Therefore i can't reach any further than one directory so reaching something like main/example/target.less would not work. However, main/target.less would. @import "star/shared"; @import "star/phone"; @import "star/tablet";

Overall there seems to be an issue with using ** to go through multiple directories and I'm not quite sure.

I've tried ./**/shared; to ensure the directory base is correct and no avail.

danpottshimself avatar Sep 01 '16 14:09 danpottshimself

Hello. I created a test project with the following directory structure

src/
├── a
│   └── b
│       └── tablet.less
└── index.less

where index.less has the following import

@import "**/tablet";

And it is being resolved properly. I have used less-cli directly, without build tools. If you have different use-case, let me know.

just-boris avatar Sep 03 '16 10:09 just-boris

index.less with following import fails

@import "**/*.less"
src/
├── a
│   └── foo.less
├── bar.less
└── index.less

I am using the plugin with Grunt. package.json looks like this

 "grunt-contrib-less": "1.4.0",
"less-plugin-glob": "2.0.0",
...

The Error Message is

Running "less:dist" (less) task
>> ParseError: Unrecognised input in /home/.../node_modules/less/test/less-bom/errors/bad-variable-declaration1.less on line 1, column 1:
>> 1 @@demo: "hi";

philipp-serfling avatar Feb 16 '17 12:02 philipp-serfling

Hello @looser,

Your wildcard seems very broad. It literally includes all files from your project, including node_modules folder. Try to adjust the glob expression to something more specific, like ./**/*.js.

just-boris avatar Feb 16 '17 13:02 just-boris

Oh i am sorry, maybe src was not the best word for that folder. Imagine that under src ther are only *.less files and folders containing *.less files. The node_modules folder is on a different path.

But @import "./**/*.less" is also throwing an ParseError. It seems like that the import expression must not start with a glob expression. Working: @import "bar.less" @import "a/foo.less" @import "a/*.less" @import "../src/**/*.less"

Not working: @import "*.less" @import "./*.less" @import "./**/*.less" @import "**/*.less"

philipp-serfling avatar Feb 20 '17 08:02 philipp-serfling

+1 thx @looser for the tip of @import "../app/**/*.less" instead of @import "**/*.less" which are equal for me.

It seems that if the plugin sees ** first in the string, it bugs. Put a ../app/ in front of it works, but damn it's ugly :P

julie75p avatar Apr 22 '17 15:04 julie75p

totally agree :)

philipp-serfling avatar Apr 22 '17 21:04 philipp-serfling

Hello! I have dome some experiments, and there is a branch with the fix: paths-selection.

It does smart logic and tries to match paths one-by-one in order to understand what import did you mean. Even though all tests are passing, it will be a breaking change, because the behavior is actually changed.

Also you can help me with releasing this if you will install feature-branch instead of stable release, and check whether it works. You can install feature branch doing:

npm install github:just-boris/less-plugin-glob#paths-selection

just-boris avatar Apr 30 '17 13:04 just-boris

This looks all very promising

Now working: @import "*.less" @import "./*.less" @import "./**/*.less" @import "**/*.less"

Not working: -

thank you!

philipp-serfling avatar May 08 '17 07:05 philipp-serfling

i guess this can be closed then.

philipp-serfling avatar Sep 29 '17 08:09 philipp-serfling