Skip to content
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 should not be compiled #3

Closed
hlascelles opened this issue Oct 25, 2011 · 9 comments
Closed

Imports should not be compiled #3

hlascelles opened this issue Oct 25, 2011 · 9 comments

Comments

@hlascelles
Copy link

Great plugin... but I'm having trouble with imports.

I have two files thus:

baseline.less
forms.less

Baseline declares a variable @baseline and imports forms with @import "forms.less";

less-sbt compiles baseline.less just fine.

But then immediately afterwards, less-sbt tries to compile forms.less which has no reference to @baseline and it tanks.

Lift/compile:less: error occured while compiling /less/forms.less: variable @baseline is undefined

I tried moving the imports to another dir and rereferencing, but then baseline won't compile. Is there a way to exclude compilation of imports?

A great project to try this on is twitter bootstrap.

Thanks!

@hlascelles
Copy link
Author

Ah, just seen the settings section, trying it now...

@hlascelles
Copy link
Author

Filters worked, but includes don't... Am getting:

Lift/compile:less: error occured while compiling /less/bootstrap.less: TypeError: Cannot call method "slice" of undefined (less-rhino-1.1.3.js#2404)

Using: sbt 0.11.0

Thanks for any guidance!

@softprops
Copy link
Owner

Hey thanks for reporting to this. I try to get to it tonight.

softprops added a commit that referenced this issue Oct 26, 2011
softprops added a commit that referenced this issue Oct 26, 2011
softprops added a commit that referenced this issue Oct 26, 2011
…pt which broke imports reported in #3. refactor compiler to access a name which services as a reference point for resolving embedded imports in less files
@softprops
Copy link
Owner

@hlascelles would you mind cloning this locally and doing a publish local to see if these changes fix your build. The version should now be @ 0.1.2-SNAPSHOT so update your projects plugin def after publishing locally.

I wrote a scripted test should should test that imports work. The test is basically that I have a a.less file which imports a variale from b.less and assert it gets properly injected. I also don't think it hurts to have b.less included but if you wanted to exclude it. use

(LessKeys.excludeFilter in (Compile, LessKeys.less)) ~= { ff => ff || "b.less" }

If you were curious ~= augments an existing setting. So here I am saying take the original filter and add an or condition of the file I want to exclude.

See https://github.com/softprops/less-sbt/blob/master/src/sbt-test/less-sbt/imports/build.sbt#L3 for what I mean.

If this fixes your build, I'll do a 0.1.2 release

@dimensia
Copy link

dimensia commented Nov 4, 2011

I am seeing this issue as well. For now I just copied all the data from my include file into the main file and it seems to work.

@softprops
Copy link
Owner

Did either of you try my fix yet? I have a scripted test for this use case which I thinks fixes the issue but I'd like to get one of you guys to do a publish local to see if it fixes your specific issue before I do another release

You can see the test project at

https://github.com/softprops/less-sbt/tree/master/src/sbt-test/less-sbt/imports

My test case was simple, I had a.less import a property from b.less and then validated that what was generated was what I expected

https://github.com/softprops/less-sbt/blob/master/src/sbt-test/less-sbt/imports/src/main/less/a.less

Confirmation on whether this fix helps your issues would help my confidence in pushing the fix in a new release.

@dimensia
Copy link

dimensia commented Nov 4, 2011

I just tried 0.1.2-SNAPSHOT and it worked for me.

@softprops
Copy link
Owner

Okay thanks @dimensia. Thanks for testing. I'll push an 0.1.2 release tomorrow

@softprops
Copy link
Owner

published http://implicit.ly/less-sbt-012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants