press icon indicating copy to clipboard operation
press copied to clipboard

LESS support (latest version, for twitter bootstrap 2)

Open lnbogen opened this issue 13 years ago • 52 comments

Hi dirkmc,

Until now, I worked with less 0.9.1. I want to use press but I have conflicts with versions (less 0.9.1 links to rhino-1.7R3.jar).

Any idea when a new version that supports less, with the latest engine (lesscss-engine-1.3.0.jar) ?

Thanks, Oren

lnbogen avatar May 31 '12 15:05 lnbogen

Hi, I'm planning to make press much more modular so it will be possible to add support for other engines as well, such as stylus and sass. I'm going to say that I'll do it by the end of the week to put a bit of pressure on myself, otherwise I'll never get round to it. Please complain if it's not done by then :)

dirkmc avatar Jun 01 '12 17:06 dirkmc

That would be amazing! Thanks!

lnbogen avatar Jun 01 '12 18:06 lnbogen

Hi dirckmc, (quietly) complaining :)

lnbogen avatar Jun 04 '12 10:06 lnbogen

When I said the end of the week, I meant the end of this week :)

dirkmc avatar Jun 04 '12 20:06 dirkmc

Hi dirckmc, is there a way to do a quick get-around myself (at least to make it to play nicely with less 0.9.1)?

lnbogen avatar Jun 11 '12 13:06 lnbogen

Hi, I'm working on making the change now. Hopefully it will be done by tomorrow. Dirk

dirkmc avatar Jun 11 '12 14:06 dirkmc

I've deployed the latest release to the module repo, version 1.0.27. Please try it out and let me know how you go.

dirkmc avatar Jun 12 '12 14:06 dirkmc

Great, thanks! Will report...

lnbogen avatar Jun 12 '12 15:06 lnbogen

I still see that you're using and old less engine (we're using lesscss-engine-1.3.0.jar to support twitter's bootstrap 2). In addition, there is still clash with less 0.9.1 module. As I've mentioned, less 0.9.1 uses rhino-1.7R3.jar and there is some conflict. What do you recommend doing?

lnbogen avatar Jun 12 '12 18:06 lnbogen

[some background] An easy way to reproduce it is to set up an application with dependencies.yml to include both press 1.0.27 and less 0.9.1. We're pretty happy with less module for the css part, it handles combining, minification is less important due to gzip. We want to use press to handle our js combining/minifcation (and obviously versioning).

lnbogen avatar Jun 12 '12 19:06 lnbogen

Oh I didn't realize I was using an old less engine, I just used the one that another person who made a pull request put in there. If I used a newer version of the less engine jar will that solve the problem? Or will it still have a conflict with less? I guess in that case you could just use press instead of the less module

dirkmc avatar Jun 12 '12 19:06 dirkmc

Ok I've updated the version of the less library to 1.3.0. Try out the latest version of press, 1.0.29

dirkmc avatar Jun 12 '12 19:06 dirkmc

were you able to run a local application with both dependencies:

  • play -> less 0.9.1
  • play -> press 1.0.29

?

lnbogen avatar Jun 12 '12 19:06 lnbogen

I haven't tried it.. did you try it and have a problem? I've updated to less-engine-1.3.0

dirkmc avatar Jun 12 '12 19:06 dirkmc

I tried less-0.9.1 and press-1.0.29 and it seems to work fine

dirkmc avatar Jun 12 '12 20:06 dirkmc

Alright, then I'll try to test everything locally with bootstrap.less file in the

and see if it's good.

lnbogen avatar Jun 12 '12 20:06 lnbogen

I get a strange behavior. I've fetched less module from github (https://github.com/lunatech-labs/play-module-less) Once I download it, I go to play-module-less\samples-and-tests\bootstrap-sample and configure dependencies.yml with both less 0.9.1 and press 1.0.29. Run play deps --sync.

Open the homepage (where it has bootstrap.less file that should run via less module, not press!) - you'll see that the css returns with "\n" (as if press changed it) which is corrupted. I've made sure (application.conf) that press.enabled was set to false and didn't add it to routes. The plugin should not have worked and yet it somehow change .less file.

In addition, removing press 1.0.29 from the dependencies solves it. Maybe by adding press 1.0.29 it somehow makes less module misbehave?

lnbogen avatar Jun 13 '12 09:06 lnbogen

Hey Oren, That is strange. I tried out a sample less file with the less module, with press, and with a combination of the two. It all works fine for me, the less files are compiled to css on the fly, and the press files are compressed without a problem. I'm not sure what else could be going wrong.

dirkmc avatar Jun 13 '12 12:06 dirkmc

Dirk, can you please pull https://github.com/lnbogen/bootstrap-sample and see test it there?

I get -

@6alf7a98g Internal Server Error (500) for request GET /press/js/DXbXyueZQbqCpnMGQZgqrAJJ.js

Execution exception (In {module:press-1.0.29}/app/press/ScriptCompressor.java around line 84) NoSuchMethodError occured : org.mozilla.javascript.Parser.parse(Ljava/io/Reader;Ljava/lang/String;I)Lorg/mozilla/javascript/ScriptOrFnNode;

play.exceptions.JavaExecutionException: org.mozilla.javascript.Parser.parse(Ljava/io/Reader;Ljava/lang/String;I)Lorg/mozilla/javascript/ScriptOrFnNode; at play.mvc.ActionInvoker.invoke(ActionInvoker.java:231) at Invocation.HTTP Request(Play!) Caused by: java.lang.NoSuchMethodError: org.mozilla.javascript.Parser.parse(Ljava/io/Reader;Ljava/lang/String;I)Lorg/mozilla/javascript/ScriptOrFnNode; at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:312) at com.yahoo.platform.yui.compressor.JavaScriptCompressor.(JavaScriptCompressor.java:533) at press.ScriptCompressor.compress(ScriptCompressor.java:84) at press.Compressor.compress(Compressor.java:164) at press.Compressor.writeCompressedFile(Compressor.java:143) at press.Compressor.getCompressedFile(Compressor.java:123) at press.Compressor.getCompressedFile(Compressor.java:91) at controllers.press.Press.getCompressedJS(Press.java:29) at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:551) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161) ... 1 more

lnbogen avatar Jun 17 '12 16:06 lnbogen

Hey Oren, Thanks a lot for taking the time to help out with debugging. It seems that both yui-compressor and lesscss-engine rely on Rhino (a Java -> JavaScript bridge). The problem is that yui-compressor takes the rhino jar, uncompresses it, and then modifies the classes, to produce a new Rhino jar. As far as I can tell the modified version of Rhino is not compatible with what lesscss-engine needs.

I'm not really sure how to get around this problem. Is it possible for you to use press to compress the less files instead of less? Dirk

dirkmc avatar Jun 18 '12 09:06 dirkmc

Tried to remove less and use press only (you can pull again, I've pushed the change). Also - did play deps --sync and play clean to make sure nothing is being saved locally other than press. Anyway, as you can see, the returned css is malformed..

lnbogen avatar Jun 18 '12 13:06 lnbogen

In addition, I see you're using 2.4.6 version of yui-compressor. Thinking of moving to 2.4.7? Might solve known bugs and dependency issues?

http://www.yuiblog.com/blog/2011/11/14/announcing-yui-compressor-2-4-7/

lnbogen avatar Jun 18 '12 14:06 lnbogen

Ugh this dependency stuff is such a pain. Ok I'll try again and see if I can find the problem with CSS compression.

With regards to your question about moving to a later version of yui-compressor: I tried compiling yui-compressor from source with the same version of Rhino that lesscss-engine uses, but I had the same problem because yui-compressor actually overwrites the Rhino classes and makes its own version of the jar. It's this modified Rhino jar that conflicts with the normal Rhino jar that lesscss-engine includes.

dirkmc avatar Jun 18 '12 14:06 dirkmc

By the way in main.html line 108 there's a space before the closing quote that causes an error (on the Mac at least): #{press.script 'bootstrap-transition.js ' /}

Also there's no need to check in /public/bootstrap/js/press, this is a temporary directory generated by press on the fly.

dirkmc avatar Jun 18 '12 14:06 dirkmc

about the bug - thanks! fixed. I need to update my gitignore although it's not critical, this is just a demo app :)

Regarding the dependencies - it's a mess indeed. This should be solved so both modules could co-exist as they offer different behavior (for example, the less module cache strategy is better as it checks for internal dependencies via "import *.less" files).

Sorry I cannot help more

lnbogen avatar Jun 18 '12 14:06 lnbogen

Ok I've upgraded the version of yui compressor to 2.4.7, it seems to be working a bit better now, at least the files are not empty and there are no exceptions, although when I tried it with your project it seems like there was some weird escaping going on with \n. Try out version 1.0.30 of the plugin and let me know if it works better for you.

dirkmc avatar Jun 18 '12 15:06 dirkmc

Yea, I saw the "\n" thus "as you can see, the returned css is malformed.." :/

Notice that it happens regardless of the less module (which is not installed). Obviously, there is something going on with the press module and less file.

lnbogen avatar Jun 19 '12 07:06 lnbogen

I don't have the issue with CSS in my own tests, I wonder if the less files have a weird encoding? I'm using a Mac and you're using Windows, right? Perhaps that makes a difference with the latest version of lesscss-engine. Are you using any special configuration options with the less module? I'm going to check out the source code to see if there are any differences.

dirkmc avatar Jun 19 '12 07:06 dirkmc

I'm using windows... You need to test it with less (try the new syntax by bootstrap 2, this is what I've used for my demo).

No special configuration option for the less module.

lnbogen avatar Jun 19 '12 07:06 lnbogen

Some strange behavior I see (maybe due to how play/modules work that I do not understand). Tried to: use less via dependency: play -> less 0.9.1 use press as local repository (after doing pull of your latest commits)

Then it works... How is that possible? Different behavior for local repository module? So much voodoo with these dependencies on Rhino.

lnbogen avatar Jun 19 '12 07:06 lnbogen