Open danpottshimself opened 8 years ago
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.
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";
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
.
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"
+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
totally agree :)
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
This looks all very promising
Now working:
@import "*.less"
@import "./*.less"
@import "./**/*.less"
@import "**/*.less"
Not working:
-
thank you!
i guess this can be closed then.
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.