-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imports reference broken #22
Comments
So it's not just me doing something wrong. :) Confirmed. |
Strange, sorry I don't know how I missed this issue. wasn't intentional. I'll look into it! |
I've been trying to debug this, but it's working fine for me. I have a hunch that it has something to do with self-referencing files. Have you both tried using the feature with just a couple of files? that will help me know where to focus |
That's weird then. I just did some testing and reduced my case down to just two minimal files. One for reference use containing a single mixin definition. And one 'regular' src file. No import statements in either file. less: {
ref: {
options: {
imports: {
reference : ['<%=tcBase%>/css/lib/reference/test.less']
}
}
,src : '<%=tcBase%>/css/lib/test.less'
,dest: '<%=destCss%>/ref.css'
}
} But Less doesn't know about the mixin and aborts. I tried it with relative and absolute paths. |
Aha! just wrote some garbage in the 'reference' file, but Less did not complain about that at all. Just about the missing mixing. Apparently the file is not being read at all. |
It might be that the templates aren't being expanded. Yeah, I just pulled it down and started playing around with it from scratch. I also installed Bootstrap using bower, then I setup a task to compile each less file to a separate CSS file using |
Haha, well you did warn me that assemble-less is experimental in nature. So you are reproducing the problem? For me there's no urgency to get this fixed. If you can debug it sometime next week that's fine with me. Get well soon! |
Yes, I did in fact reproduce the issue. one problem is that files added to any of the // Probably the biggest hit on task execution time.
var parseImports = function(options) {
var directives = _.pairs(options.imports);
var statement = '';
directives.forEach(function(pair) {
pair[1].map(function(filepath) {
// Don't add a circular reference.
if (!!~srcFile.search(filepath)) {
return;
}
statement += '@import (' + pair[0] + ') "' + filepath + '";\n';
});
});
return statement;
};
srcCode += parseImports(options);
srcCode += file.readFileSync(srcFile); Now I'm refactoring how metadata works so that it doesn't mutate upstream values and cause unexpected issues in other grunt tasks! Yikes! I'm probably going to have to implement more rigid conventions around how data is defined. ... huh, actually I completely forgot that I created this lib until just now lol. I can use this to solve it. I'll let you know when I have something... and thank you! I appreciate it! |
See: b8d41f6 This is the v0.8.0 branch, you'll have to pull it down with git or download manually to test it. let me know if it works for you. If there are problems unrelated to this one, please open new tickets for those. |
also, if you set |
@AlistairB / @MarcDiethelm ping. any feedback on v0.8.0? Just do this to install: git clone -b "v0.8.0" https://github.com/assemble/assemble-less.git && cd assemble-less && npm i |
:) Today is the first day that I actually have time to test it. So I just opened this issue again to check out your instructions for testing and I find your new comment... It's working! Albeit there's another issue:
paths: ['<%=assetBase%>/css/lib/reference']
,imports: {
reference : ['*.less'] // no worky
} FYI: I initially constructed the path myself: reference: [path.relative(srcAbsolute, '<%=assetBase%>/css/lib/reference')+'/helpers.less'] That's probably quite a bit more efficient than using |
Yeah I think I mentioned in the commit messages that I intentionally took that out, because it increases build time and it's just brittle. Even if you only reference files one folder deep (e.g. |
Mmh yes, for me it's a prerequisite to using it. I don't want users to have to configure Grunt, instead they can use folders to drop their assets into, like the |
Well, let me clarify. The additional logic required for this feature slows down the build appreciably when any patterns are used. period. however, since I didn't do any actual benchmarking and I don't have any numbers to report, the amount is still conjecture. So I'll try re-adding it and see how it works out. One more thing. The problem exponentially compounds when you add |
I was actually surprised that it did work and However to an extent (which I don't understand) it surely depends on how its being used. Adding some stern warnings in the docs might be the thing to do here. Because it's also nice to be able to use this power if someone needs it. I really don't understand enough about the internals of assemble-less and the relationship between it and less to make any sound judgements, I'm afraid. But I'll use my use case as an example here. I'm 'only' looking for files to use with Using |
Currently it's tied to
this can be done with lodash templates. e.g. base: 'foo'
less: {
options: {
imports: {
reference: ['<%= base %>/mixins.less']
}
}
} Okay, I need to think about this a little bit. maybe we should create an example project where each of us adds a config and some example less files, so we can share our practices and see how things can be improved. I have a hunch this can resolve some things tool. |
Thanks for all your great help so far! Re: example project... Sure let's do that. My actual 'real' use case is something that I have not started implementing yet. Which would be 'bundling' some frontend 'modules/components' together (JS, CSS, maybe also markup/templates) to be used as assets for discrete sections of a website. That's what I think I'll eventually be using It probably best if you set up a repo and maybe add me as a collaborator. Or, if you prefer I can do it. |
Sure, I'll set something up. Might be tomorrow, I'll let you know when I have something |
@jonschlinkert: My turn to remind you. |
I ran into this issue today and I'm a bit surprised that it has been fixed already for almost a year in the 0.8 branch but is still broken in the version that npm installs. Would be nice to get it working from there too. |
Hi,
I updated from (i think) .5 to .7 and imports > reference stopped working
I have changed imports > less to imports > reference. But it wont compile because it can't find mixins in mixins.less.
Any ideas? Any way I can get more information on what is happening?
The text was updated successfully, but these errors were encountered: